-
-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 useExhaustiveDependencies error on JSON.stringify
as dep.
#577
Comments
The first statement (from both Biome and ESLint plugin) is wrong. Dependency is not missing, it is specified in just "a different way". The only correct way of using objects as dependency in useMemo/useEffect is to convert it to either string or hash it in other ways as comparing objects will never result in true. Using an object will result in re-render every single time, and it would be the same as using useMemo/useEffect without dependencies. In the case of |
If you think it's a valid bug, you should file an issue to their repository, after all it's maintained by the react core team. The intention of Biome 's rule is to replicate as much as possible from the original rule, and not deviate from it. Happy to resume the discussion once this is solved. |
There is no "different way", |
This is why passing |
Only if you change the reference with the action provided by the |
Environment information
What happened?
JSON.stringify
as useMemo dependency.This hook do not specify all of its dependencies.
andThis hook specifies more dependencies than necessary.
error.https://biomejs.dev/playground/?code=aQBtAHAAbwByAHQAIAB7ACAAdQBzAGUAUwB0AGEAdABlACwAIAB1AHMAZQBFAGYAZgBlAGMAdAAgAH0AIABmAHIAbwBtACAAJwByAGUAYQBjAHQAJwA7AAoACgBlAHgAcABvAHIAdAAgAGMAbwBuAHMAdAAgAEMAbwBtAHAAbwBuAGUAbgB0ACAAPQAgACgAKQAgAD0APgAgAHsACgAgACAAYwBvAG4AcwB0ACAAWwBvAGIAagBlAGMAdABDAG8AbgB0AGUAbgB0AF0AIAA9AAoAIAAgACAAIAB1AHMAZQBTAHQAYQB0AGUAPAB7AGQAYQB0AGEAOgAgAHMAdAByAGkAbgBnAH0APgAoAHsAZABhAHQAYQA6ACAAIgBuAG8AbgBlACIAfQApADsACgAKACAAIAB1AHMAZQBFAGYAZgBlAGMAdAAoACgAKQAgAD0APgAgAHsACgAgACAAIAAgAGMAbwBuAHMAbwBsAGUALgBsAG8AZwAoAG8AYgBqAGUAYwB0AEMAbwBuAHQAZQBuAHQAKQA7AAoAIAAgAH0ALAAgAFsASgBTAE8ATgAuAHMAdAByAGkAbgBnAGkAZgB5ACgAbwBiAGoAZQBjAHQAQwBvAG4AdABlAG4AdAApAF0AKQA7AAoACgAgACAAcgBlAHQAdQByAG4AIABvAGIAagBlAGMAdABDAG8AbgB0AGUAbgB0ADsACgB9ADsACgA%3D
Expected result
It should show no error.
Code of Conduct
The text was updated successfully, but these errors were encountered: