npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@react-native-extra/media-query

v0.4.9

Published

The library contains media query hooks and component for react-native and react

Downloads

49

Readme

Media query

This library contains media query hooks and media query components that can ease the development of responsive design in react native and react.


Sections

The library is divided in 4 parts:

  1. useMediaQuery hook and OnMediaQuery component

  2. Create media query hooks and components from string

  3. Create media query hooks and components from context

useMediaQuery hook and OnMediaQuery component


Example on how to use useMediaQuery hook and OnMediaQuery component

import React from "react";

import { View, Text } from "react-native";

import { useMediaQuery, OnMediaQuery } from "@react-native-extra/media-query";



export const Root = () => {

    const isPortrait = useMediaQuery("(orientation: portrait)");

    return (
        <>
            <Text>
                {isPortrait 
                ? "Portrait" 
                : "Landscape"}
            </Text>

            <OnMediaQuery 
            query="(orientation: portrait)">
                <Text>
                    Portrait
                </Text>
            </OnMediaQuery>
        </>
    );
};

Create media query hooks and components from string


You could also create media query components or hooks from strings

import React from "react";

import { View } from "react-native";

import { 
    createMediaQueryHookFromString,
    createMediaQueryComponetFromString,
} 
from "@react-native-extra/media-query";



const OnLaptop = createMediaQueryComponetFromString("(min-width: 1128px)");

const useOnLaptop = createMediaQueryHookFromString("(min-width: 1128px)");

export const Root = () => {

    const isOnLaptop = useOnLaptop();

    return (
        <>
            <Text>
                {isOnLaptop 
                ? "On laptop" 
                : "Not on laptop"}
            </Text>

            <OnLaptop>
                <Text>
                    Laptop
                </Text>
            </OnLaptop>
        </>
    );
};

Create media query hooks and components from context


You could also create media query components or hooks from a context. The context must be an object. That has property named breakpoints. The breakpoint property has the value of an object whose keys are the breakpoint name and values are media query string.

import React, { createContext } from "react";

import { View } from "react-native";

import { 
    createMediaQueryHookFromContext,
    createMediaQueryComponetFromContext
} 
from "@react-native-extra/media-query";




const ThemeContext = createContext({
    breakpoints: {
        portrait: "(orientation: portrait)",
        landscape: "(orientation: landscape)",
    }
});

const useOnBreakpoint = createMediaQueryHookFromContext(ThemeContext);

const OnBreakpoint = createMediaQueryComponetFromContext(ThemeContext);

export const Root = () => {

    const isPortrait = useOnBreakpoint("portrait");

    const isLandscape = useOnBreakpoint("landscape");

    return (
        <>
            {isPortrait &&
            <Text>
                Portrait
            <Text>}

            {isLandscape &&
            <Text>
                Landscape
            <Text>}


            <OnBreakpoint 
            breakpoint="portrait">
                <Text>
                    Portrait
                </Text>
            </OnBreakpoint>

            <OnBreakpoint
            breakpoint="landscape">
                <Text>
                    Landscape
                </Text>
            </OnBreakpoint>
        </>
    );
};