@shopify/react-hooks
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -19,3 +19,2 @@ 'use strict'; | ||
} | ||
const timeout = setTimeout(() => { | ||
@@ -22,0 +21,0 @@ stateRef.current = value; |
@@ -16,3 +16,2 @@ 'use strict'; | ||
}, []); | ||
function callbackWithDelay() { | ||
@@ -25,3 +24,2 @@ const timeoutId = setTimeout(() => { | ||
} | ||
return callbackWithDelay; | ||
@@ -28,0 +26,0 @@ } |
@@ -14,4 +14,5 @@ 'use strict'; | ||
function useInterval(callback, delay) { | ||
const savedCallback = React.useRef(callback); // Need to use a layout effect to force the saved callback to be synchronously updated during a commit | ||
const savedCallback = React.useRef(callback); | ||
// Need to use a layout effect to force the saved callback to be synchronously updated during a commit | ||
isomorphicLayoutEffect.useIsomorphicLayoutEffect(() => { | ||
@@ -24,3 +25,2 @@ savedCallback.current = callback; | ||
} | ||
if (delay !== null) { | ||
@@ -30,3 +30,2 @@ const id = setInterval(tick, delay); | ||
} | ||
return undefined; | ||
@@ -33,0 +32,0 @@ }, [delay]); |
@@ -7,9 +7,10 @@ 'use strict'; | ||
// https://github.com/facebook/react/blob/master/packages/shared/ExecutionEnvironment.js | ||
const canUseDOM = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined'; | ||
/** | ||
* A hook that resolves to useEffect on the server and useLayoutEffect on the client | ||
*/ | ||
const useIsomorphicLayoutEffect = canUseDOM ? React.useLayoutEffect : React.useEffect; | ||
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect; |
@@ -14,7 +14,4 @@ 'use strict'; | ||
} | ||
const matchMedia = window.matchMedia(query); | ||
const updateMatch = event => setMatch(event.matches); | ||
setMatch(matchMedia.matches); | ||
@@ -29,3 +26,2 @@ matchMedia.addListener(updateMatch); | ||
} | ||
const useMedia = createUseMediaFactory(React.useEffect); | ||
@@ -32,0 +28,0 @@ const useMediaLayout = createUseMediaFactory(React.useLayoutEffect); |
@@ -15,3 +15,2 @@ 'use strict'; | ||
const oldValue = tracked.current; | ||
if (value !== tracked.current) { | ||
@@ -18,0 +17,0 @@ tracked.current = value; |
@@ -9,4 +9,5 @@ 'use strict'; | ||
function useTimeout(callback, delay) { | ||
const savedCallback = React.useRef(callback); // Need to use a layout effect to force the saved callback to be synchronously updated during a commit | ||
const savedCallback = React.useRef(callback); | ||
// Need to use a layout effect to force the saved callback to be synchronously updated during a commit | ||
isomorphicLayoutEffect.useIsomorphicLayoutEffect(() => { | ||
@@ -19,3 +20,2 @@ savedCallback.current = callback; | ||
} | ||
if (delay !== null) { | ||
@@ -25,3 +25,2 @@ const id = setTimeout(tick, delay); | ||
} | ||
return undefined; | ||
@@ -28,0 +27,0 @@ }, [delay]); |
@@ -11,3 +11,2 @@ 'use strict'; | ||
*/ | ||
function useToggle(initialState) { | ||
@@ -14,0 +13,0 @@ const [value, setState] = React.useState(initialState); |
{ | ||
"name": "@shopify/react-hooks", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"license": "MIT", | ||
@@ -48,5 +48,5 @@ "description": "A collection of primitive React hooks", | ||
"devDependencies": { | ||
"@shopify/jest-dom-mocks": "^5.0.0", | ||
"@shopify/react-testing": "^5.1.4" | ||
"@shopify/jest-dom-mocks": "^5.0.1", | ||
"@shopify/react-testing": "^5.1.5" | ||
} | ||
} |
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
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37483
481