Bug: `react-hooks/exhaustive-deps` does more than checking deps and cannot be configured for intended behavior

#33703

Issue Details

29 days ago
No assignee
Status: Unconfirmed
marcospgpmarcospgp
opened 29 days ago
Author

I configured the react-hooks/exhaustive-deps eslint rule to lint my useAsyncEffect custom hook:

"react-hooks/exhaustive-deps": [ "warn", { additionalHooks: "(useAsyncEffect)", }, ],

but whenever I use it, it doesn't just make sure I include all dependencies in the deps array, it also errors with this:

Effect callbacks are synchronous to prevent race conditions. Put the async function inside: useEffect(() => { async function fetchData() { // You can await here const response = await MyAPI.getData(someId); // ... } fetchData(); }, [someId]); // Or [] if effect doesn't need props or state Learn more about data fetching with Hooks: https://react.dev/link/hooks-data-fetchingeslint[react-hooks/exhaustive-deps](https://github.com/facebook/react/issues/14920)

passing an async function to my custom useAsyncEffect hook is intended behavior.

the eslint rule react-hooks/exhaustive-deps is doing too much - these checks are separate and should be split into different rules, as per the single responsibility principle

at the least there should be a way to configure the rule so that I could use it with my custom hook