|
const preservedCallback = usePreservedCallback(callback); |
As you can see from the above code, you created a 'preservedCallback' using 'usePreservedCallback' to keep a reference to the 'callback'.
|
[preservedCallback, ...deps] |
When wrapping 'useCallback' to maintain a reference to 'effect', the return value of 'useRefEffect'. you use 'preservedCallback' created in 15L as a dependency.
|
const cleanup = callback(element); |
But, the function used inside 'effect', which is the return value, uses 'callback', not 'preservedCallback'.
Is this intended behavior?
[ 1 ]
If you don't want to affect the 'effect' reference change due to the reference change of 'callback', use 'preservedCallback' in deps, but the actual operation is to use callback.
I'm wondering if I need to use 'preservedCallback' when using 'eslint-disable'.
[ 2 ]
To avoid confusion in code
|
const cleanup = callback(element); |
I'm thinking that maybe I should use 'preservedCallback' instead of 'callback' in the above code.
slash/packages/react/react/src/hooks/useRefEffect.ts
Line 15 in 570759f
As you can see from the above code, you created a 'preservedCallback' using 'usePreservedCallback' to keep a reference to the 'callback'.
slash/packages/react/react/src/hooks/useRefEffect.ts
Line 32 in 570759f
When wrapping 'useCallback' to maintain a reference to 'effect', the return value of 'useRefEffect'. you use 'preservedCallback' created in 15L as a dependency.
slash/packages/react/react/src/hooks/useRefEffect.ts
Line 24 in 570759f
But, the function used inside 'effect', which is the return value, uses 'callback', not 'preservedCallback'.
Is this intended behavior?
[ 1 ]
If you don't want to affect the 'effect' reference change due to the reference change of 'callback', use 'preservedCallback' in deps, but the actual operation is to use callback.
I'm wondering if I need to use 'preservedCallback' when using 'eslint-disable'.
[ 2 ]
To avoid confusion in code
slash/packages/react/react/src/hooks/useRefEffect.ts
Line 24 in 570759f
I'm thinking that maybe I should use 'preservedCallback' instead of 'callback' in the above code.