profile
viewpoint

Ask questionsBug: [eslint-plugin-react-hooks] exhaustive-deps doesn't allow for array hashing

I'm not sure how to file this. Please let me know if I need to adjust anything. Thanks!

React version: 16.13.0

Steps To Reproduce

  1. Create a useEffect hook that accesses an array whose identity might change, even when its contents do not
  2. Attempt to provide a hashed value of the array as a dependency
  3. See react-hooks/exhaustive-deps give the following error: "React Hook useEffect has a missing dependency"

image

image

Link to code example:

https://codesandbox.io/s/eloquent-hellman-8n4hz

The current behavior

There doesn't seem to be any way to tell exhaustive-deps to allow a function to be used to calculate a deterministic hash of a dependent array for the purpose of knowing when that array's contents have changed (since useEffect compares arrays by identity, not by contents)

The expected behavior

There should be some way to do this?

facebook/react

Answer questions vkurchatkin

There should be some way to do this?

There is: eslint-disable-next-line

useful!

Related questions

Disable react strict mode on third party libraries hot 6
Refs - "object is not extensible" hot 4
Warning: Unknown DOM property for. Did you mean htmlFor? hot 4
React@16.9 block `javascript:void(0);` hot 4
TypeError: Object(...) is not a function hot 3
Warning: validateDOMNesting(...): <tr> cannot appear as a child of <table> hot 3
React custom hook "Should have a queue. This is likely a bug in React" error message. hot 2
useEffect causes 'callback is not a function' exception hot 2
DevTools: Updating state or props in devtools does not trigger component update. hot 2
Infinite loop in useEffect using blank object or array hot 2
False-positive security precaution warning (`javascript:` URLs) hot 2
Hooks API - hook breaks when exported from module hot 2
Function components do not support contextType. hot 2
Feedback on useEffect depndencies change error hot 2
[ESLint] Feedback for 'exhaustive-deps' lint rule hot 2
Github User Rank List