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

@shopify/react-hooks

Package Overview
Dependencies
Maintainers
13
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/react-hooks - npm Package Compare versions

Comparing version 1.8.0 to 1.9.0

6

CHANGELOG.md

@@ -10,2 +10,8 @@ # Changelog

## [1.9.0] - 2020-04-23
### Added
- Added `useMediaLayout` hook ([#1396](https://github.com/Shopify/quilt/pull/1396))
## [1.8.0] - 2020-04-14

@@ -12,0 +18,0 @@

3

dist/src/hooks/media.d.ts

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

export declare function useMedia(query: string): boolean;
export declare const useMedia: (query: string) => boolean;
export declare const useMediaLayout: (query: string) => boolean;
//# sourceMappingURL=media.d.ts.map

@@ -5,18 +5,23 @@ "use strict";

var react_1 = require("react");
function useMedia(query) {
var _a = tslib_1.__read(react_1.useState(false), 2), match = _a[0], setMatch = _a[1];
react_1.useEffect(function () {
if (!window || !window.matchMedia) {
return;
}
var matchMedia = window.matchMedia(query);
var updateMatch = function (event) { return setMatch(event.matches); };
setMatch(matchMedia.matches);
matchMedia.addListener(updateMatch);
return function () {
matchMedia.removeListener(updateMatch);
};
}, [query]);
return match;
function createUseMediaFactory(useEffectHook) {
return function (query) {
var _a = tslib_1.__read(react_1.useState(false), 2), match = _a[0], setMatch = _a[1];
useEffectHook(function () {
if (!window || !window.matchMedia) {
return;
}
var matchMedia = window.matchMedia(query);
var updateMatch = function (event) {
return setMatch(event.matches);
};
setMatch(matchMedia.matches);
matchMedia.addListener(updateMatch);
return function () {
matchMedia.removeListener(updateMatch);
};
}, [query]);
return match;
};
}
exports.useMedia = useMedia;
exports.useMedia = createUseMediaFactory(react_1.useEffect);
exports.useMediaLayout = createUseMediaFactory(react_1.useLayoutEffect);
{
"name": "@shopify/react-hooks",
"version": "1.8.0",
"version": "1.9.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "A collection of primitive React hooks.",

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