Socket
Socket
Sign inDemoInstall

rn-media-query-hook

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rn-media-query-hook

React Native Media Query Hook


Version published
Maintainers
1
Created

Readme

Source

rn-media-query-hook

npm version npm downloads npm npm

React Native Media Query Hook

Demo :

https://snack.expo.dev/@fateh999/rn-media-query-hook

Steps to install :

npm install rn-media-query-hook

or


yarn add rn-media-query-hook

import useMediaQuery from "rn-media-query-hook";

// In functional component
const { mediaQuery, mediaQueryLogic } = useMediaQuery();

or

import useMediaQuery from "rn-media-query-hook";

// In functional component
const { mQ, mQL } = useMediaQuery();
Usage :
// For dimensions
const responsiveWidth = mQ([100, 200, 300, 400, 500]);

// order is important [base, sm, md, lg, xl]

// or

const responsiveWidth = mQ({ base: 100, sm: 200, md: 300, lg: 400, xl: 500 });

// For any logic
const show = mQL([true, true, true, false, false]);

// order is important [base, sm, md, lg, xl]

// or

const show = mQ({ base: true, sm: true, md: true, lg: false, xl: false });

Default Breakpoints :

const initialBreakPoints: BREAK_POINTS = {
  base: 0,
  sm: 480,
  md: 768,
  lg: 992,
  xl: 1280,
};

Custom Breakpoints :

const newBreakPoints: BREAK_POINTS = {
  base: 0,
  sm: 380,
  md: 868,
  lg: 892,
  xl: 1180,
};

// In functional component

const { mediaQuery, mediaQueryLogic } = useMediaQuery(newBreakPoints);

Note :

  • Only base dimension or logic is required, rest are optional

fateh999




Keywords

FAQs

Last updated on 04 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc