Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-hook-media

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hook-media - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

chunk-2MEHW6NA.cjs

2

configureNodeEnv/index.js

@@ -1,3 +0,3 @@

export { configureNodeEnv_default as default } from '../chunk-4ZWMFY3T.js';
export { configureNodeEnv_default as default } from '../chunk-D5APFJZD.js';
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map

@@ -1,6 +0,6 @@

export { MatchMedia_default as MatchMedia } from './chunk-FPIRNL5R.js';
export { configureNodeEnv_default as configureNodeEnv } from './chunk-4ZWMFY3T.js';
export { useMatchMedia_default as useMatchMedia } from './chunk-JTPMRFZI.js';
export { MatchMedia_default as MatchMedia } from './chunk-5LOZ4RRE.js';
export { configureNodeEnv_default as configureNodeEnv } from './chunk-D5APFJZD.js';
export { useMatchMedia_default as useMatchMedia } from './chunk-D5HRICXA.js';
export { MatchMediaHydrationProvider_default as MatchMediaHydrationProvider } from './chunk-PQCTR6QK.js';
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

export { MatchMedia_default as default } from '../chunk-FPIRNL5R.js';
export { MatchMedia_default as default } from '../chunk-5LOZ4RRE.js';
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map
{
"name": "react-hook-media",
"version": "1.0.0",
"version": "1.0.1",
"author": "Krombik",

@@ -5,0 +5,0 @@ "description": "A lightweight and tree-shakable library for working with media queries in React applications, providing responsive behavior and conditional rendering based on media query conditions.",

@@ -13,3 +13,3 @@ # react-hook-media

```
```bash
npm install --save react-hook-media

@@ -20,6 +20,12 @@ ```

```
```bash
yarn add react-hook-media
```
or pnpm:
```bash
pnpm add react-hook-media
```
---

@@ -42,8 +48,5 @@

<div>
{isDesktop ? "This is desktop" : "This is mobile"}
<MatchMedia
query="(max-width: 899px)"
otherwise={"And this is also desktop"}
>
And this is also mobile
{isDesktop ? "desktop" : "mobile"}
<MatchMedia query="(width < 900px)" otherwise={"desktop"}>
mobile
</MatchMedia>

@@ -85,5 +88,5 @@ </div>

Custom hook that implements the behavior of the [matchMedia](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) method as a React hook.
Custom hook that provides the functionality of the [matchMedia](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) method as a React hook.
> In a Node environment, this hook will always return `false` by default since media queries are not supported. However, you can customize the behavior of `useMatchMedia` by using the [configureNodeEnv](#configurenodeenv) method
> In a Node environment, where media queries are not supported, you must use the [configureNodeEnv](#configurenodeenv) method to simulate different device conditions, like in [example](#example).

@@ -127,5 +130,5 @@ Returns `true` if the media query matches, `false` otherwise.

This function is used to set up the environment for the useMatchMedia hook when running React components on the server or in testing environments. It allows you to provide a custom configuration object to simulate different media query results.
This function is used to set up the environment for the [useMatchMedia](#usematchmedia) hook when running React components on the server or in testing environments. It allows you to provide a custom configuration object to simulate different media query results.
The configuration object should contain properties that match the media query conditions you want to simulate. For example, if you configure it with `{ width: 768 }`, it will simulate the viewport width as if it were 768 pixels wide, affecting the results returned by useMatchMedia when evaluating media queries related to width.
The configuration object should contain properties that match the media query conditions you want to simulate. For example, if you configure it with `{ width: 768 }`, it will simulate the viewport width as if it were 768 pixels wide, affecting the results returned by [useMatchMedia](#usematchmedia) when evaluating media queries related to width.

@@ -132,0 +135,0 @@ Returns a `MatchMediaHydrationContext` object that should be passed to the [MatchMediaHydrationProvider](#matchmediahydrationprovider).

type UseMatchMedia = {
/**
* Custom hook that implements the behavior of the [matchMedia](#https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) method as a React hook.
* Custom hook that implements the behavior of the [matchMedia](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) method as a React hook.
*
* > In a Node environment, this hook will always return `false` by default since media queries
* > are not supported. However, you can customize the behavior of `useMatchMedia` by using the
* > `configureNodeEnv` method. See the [documentation](https://github.com/Krombik/react-hook-media#configurenodeenv) for `configureNodeEnv` for more information.
* > In a Node environment, where media queries are not supported, you must use the [configureNodeEnv](https://github.com/Krombik/react-hook-media#configurenodeenv) method to simulate different device conditions, like in this [example](https://github.com/Krombik/react-hook-media#example).
*

@@ -9,0 +7,0 @@ * @example

@@ -1,3 +0,3 @@

export { useMatchMedia_default as default, setHandler } from '../chunk-JTPMRFZI.js';
export { useMatchMedia_default as default, replaceUseMatchMedia } from '../chunk-D5HRICXA.js';
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc