Do you want to request a feature or report a bug?
Arguably a bug in eslint-plugin-react-hooks
What is the current behavior?
The exhaustive-deps rule does not catch the following case:
const FooContext = React.createContext(() => {});
// Meanwhile, somewhere deep in the component tree
function Bar() {
const foo = useContext(FooContext);
useEffect(foo, []);
return <div>A div walks into a Bar…</div>;
}
What is the expected behavior?
I think the plugin should suggest adding the dependency on foo:
It already makes this suggestion for the verbose form of the code:
// This code:
useEffect(() => foo(), []);
// is fixed to:
useEffect(() => foo(), [foo]);
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
- eslint@6.2.2
- eslint-plugin-react-hooks@2.0.1
- react@16.9.0
Do you want to request a feature or report a bug?
Arguably a bug in eslint-plugin-react-hooks
What is the current behavior?
The exhaustive-deps rule does not catch the following case:
What is the expected behavior?
I think the plugin should suggest adding the dependency on
foo:It already makes this suggestion for the verbose form of the code:
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?