From 17cecd812930847b5258dd92d10cf01d302bde06 Mon Sep 17 00:00:00 2001 From: Salmen Hichri Date: Fri, 29 Mar 2024 19:11:29 +0000 Subject: [PATCH] Updated useDeepCompareEffect --- .../core/src/hooks/useDeepCompareEffect/index.ts | 16 ++++++++-------- pipeline/npm/core/README.md | 2 +- pipeline/npm/versions.json | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/react/core/src/hooks/useDeepCompareEffect/index.ts b/packages/react/core/src/hooks/useDeepCompareEffect/index.ts index b1afff7e..cdbd4fe0 100644 --- a/packages/react/core/src/hooks/useDeepCompareEffect/index.ts +++ b/packages/react/core/src/hooks/useDeepCompareEffect/index.ts @@ -5,15 +5,15 @@ // * License: MIT // -import * as React from 'react'; +import {useEffect, useMemo, useRef} from 'react'; import {dequal as deepEqual} from '../dequal'; -type UseEffectParams = Parameters +type UseEffectParams = Parameters type EffectCallback = UseEffectParams[0] type DependencyList = UseEffectParams[1] // yes, I know it's void, but I like what this communicates about // the intent of these functions: It's just like useEffect -type UseEffectReturn = ReturnType +type UseEffectReturn = ReturnType function checkDeps(deps: DependencyList) { if (!deps || !deps.length) { @@ -37,8 +37,8 @@ function isPrimitive(val: unknown) { * @returns a memoized version of the value as long as it remains deeply equal */ export function useDeepCompareMemoize(value: T) { - const ref = React.useRef(value) - const signalRef = React.useRef(0) + const ref = useRef(value) + const signalRef = useRef(0) if (!deepEqual(value, ref.current)) { ref.current = value @@ -46,7 +46,7 @@ export function useDeepCompareMemoize(value: T) { } // eslint-disable-next-line react-hooks/exhaustive-deps - return React.useMemo(() => ref.current, [signalRef.current]) + return useMemo(() => ref.current, [signalRef.current]) } function useDeepCompareEffect( @@ -57,7 +57,7 @@ function useDeepCompareEffect( checkDeps(dependencies) } // eslint-disable-next-line react-hooks/exhaustive-deps - return React.useEffect(callback, useDeepCompareMemoize(dependencies)) + return useEffect(callback, useDeepCompareMemoize(dependencies)) } export function useDeepCompareEffectNoCheck( @@ -65,7 +65,7 @@ export function useDeepCompareEffectNoCheck( dependencies: DependencyList, ): UseEffectReturn { // eslint-disable-next-line react-hooks/exhaustive-deps - return React.useEffect(callback, useDeepCompareMemoize(dependencies)) + return useEffect(callback, useDeepCompareMemoize(dependencies)) } export default useDeepCompareEffect; diff --git a/pipeline/npm/core/README.md b/pipeline/npm/core/README.md index ec2e4850..012ef0aa 100644 --- a/pipeline/npm/core/README.md +++ b/pipeline/npm/core/README.md @@ -88,7 +88,7 @@ from [`@nlux/themes`](https://www.npmjs.com/package/@nlux/themes) or use the CDN hosted version from below: ```jsx - + ``` This CDN is provided for demo purposes only and it's not scalable. diff --git a/pipeline/npm/versions.json b/pipeline/npm/versions.json index 47195aa0..0325fa07 100644 --- a/pipeline/npm/versions.json +++ b/pipeline/npm/versions.json @@ -1,6 +1,6 @@ { "inherit": true, - "nlux": "1.0.4", + "nlux": "1.0.5", "peerDependencies": { "react": "18.2.0", "react-dom": "18.2.0"