File tree 3 files changed +7
-10
lines changed
3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 1
1
import { useRef } from 'react' ;
2
2
import type { DependencyList , useEffect , useLayoutEffect } from 'react' ;
3
- import isEqual from 'lodash/isEqual ' ;
3
+ import { depsEqual } from '../utils/depsEqual ' ;
4
4
5
5
type EffectHookType = typeof useEffect | typeof useLayoutEffect ;
6
6
type CreateUpdateEffect = ( hook : EffectHookType ) => EffectHookType ;
7
7
8
- const depsEqual = ( aDeps : DependencyList = [ ] , bDeps : DependencyList = [ ] ) => {
9
- return isEqual ( aDeps , bDeps ) ;
10
- } ;
11
-
12
8
export const createDeepCompareEffect : CreateUpdateEffect = ( hook ) => ( effect , deps ) => {
13
9
const ref = useRef < DependencyList > ( ) ;
14
10
const signalRef = useRef < number > ( 0 ) ;
Original file line number Diff line number Diff line change
1
+ import type { DependencyList } from 'react' ;
2
+ import isEqual from 'lodash/isEqual' ;
3
+
4
+ export const depsEqual = ( aDeps : DependencyList = [ ] , bDeps : DependencyList = [ ] ) =>
5
+ isEqual ( aDeps , bDeps ) ;
Original file line number Diff line number Diff line change 1
- import isEqual from 'lodash/isEqual' ;
2
1
import type { DependencyList , EffectCallback } from 'react' ;
3
2
import { useRef } from 'react' ;
4
3
import type { BasicTarget } from './domTarget' ;
5
4
import useEffectWithTarget from './useEffectWithTarget' ;
6
-
7
- const depsEqual = ( aDeps : DependencyList , bDeps : DependencyList = [ ] ) => {
8
- return isEqual ( aDeps , bDeps ) ;
9
- } ;
5
+ import { depsEqual } from './depsEqual' ;
10
6
11
7
const useDeepCompareEffectWithTarget = (
12
8
effect : EffectCallback ,
You can’t perform that action at this time.
0 commit comments