@superdispatch/hooks
Advanced tools
Comparing version
@@ -49,6 +49,8 @@ 'use strict'; | ||
var useIsomorphicLayoutEffect = typeof document != 'undefined' ? react.useEffect : react.useLayoutEffect; | ||
function useDeepEqualValue(value) { | ||
var ref = react.useRef(value); | ||
var isEqual = dequal.dequal(value, ref.current); | ||
react.useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
if (!isEqual) { | ||
@@ -80,3 +82,3 @@ ref.current = value; | ||
}); | ||
react.useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
mountRef.current = true; | ||
@@ -93,3 +95,3 @@ callbackRef.current = handler; | ||
var ref = react.useRef(false); | ||
react.useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
ref.current = true; | ||
@@ -96,0 +98,0 @@ return () => { |
import { dequal } from 'dequal'; | ||
import { useLayoutEffect, useRef } from 'react'; | ||
import { useRef } from 'react'; | ||
import { useIsomorphicLayoutEffect } from "../isomorphic-layout-effect/useIsomorphicLayoutEffect.js"; | ||
export function useDeepEqualValue(value) { | ||
var ref = useRef(value); | ||
var isEqual = dequal(value, ref.current); | ||
useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
if (!isEqual) { | ||
@@ -8,0 +9,0 @@ ref.current = value; |
@@ -1,2 +0,3 @@ | ||
import { useLayoutEffect, useRef } from 'react'; | ||
import { useRef } from 'react'; | ||
import { useIsomorphicLayoutEffect } from "../isomorphic-layout-effect/useIsomorphicLayoutEffect.js"; | ||
export function useEventHandler(handler) { | ||
@@ -20,3 +21,3 @@ var mountRef = useRef(false); | ||
}); | ||
useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
mountRef.current = true; | ||
@@ -23,0 +24,0 @@ callbackRef.current = handler; |
@@ -1,5 +0,6 @@ | ||
import { useCallback, useLayoutEffect, useRef } from 'react'; | ||
import { useCallback, useRef } from 'react'; | ||
import { useIsomorphicLayoutEffect } from "../isomorphic-layout-effect/useIsomorphicLayoutEffect.js"; | ||
export function useIsMounted() { | ||
var ref = useRef(false); | ||
useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
ref.current = true; | ||
@@ -6,0 +7,0 @@ return () => { |
@@ -45,6 +45,8 @@ import { useRef, useEffect, useLayoutEffect, useCallback } from 'react'; | ||
var useIsomorphicLayoutEffect = typeof document != 'undefined' ? useEffect : useLayoutEffect; | ||
function useDeepEqualValue(value) { | ||
var ref = useRef(value); | ||
var isEqual = dequal(value, ref.current); | ||
useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
if (!isEqual) { | ||
@@ -75,3 +77,3 @@ ref.current = value; | ||
}); | ||
useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
mountRef.current = true; | ||
@@ -88,3 +90,3 @@ callbackRef.current = handler; | ||
var ref = useRef(false); | ||
useLayoutEffect(() => { | ||
useIsomorphicLayoutEffect(() => { | ||
ref.current = true; | ||
@@ -91,0 +93,0 @@ return () => { |
{ | ||
"name": "@superdispatch/hooks", | ||
"version": "0.7.23", | ||
"version": "0.7.24", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
25404
8.18%16
6.67%298
2.05%0
-100%