Closed ravenkim closed 2 weeks ago
Neither of these are from the react plugin; you may want the react hooks plugin.
i got only these extends,
and when i remove
'plugin:react/recommended',
'plugin:react/jsx-runtime',
theses two then error disappear
and error show this error from eslint
I’m not sure how that’d be the case; the react hooks plugin is what’s generating one of the warnings.
anyway, thanks for answer!
I hope this feature added!
'react-hooks/exhaustive-deps': ['warn', {
additionalHooks: '(useMyCustomHook|useAnotherCustomHook)',
ignore: ['dispatch']
}]
That config references the react-hooks plugin, which is not this repo/project.
@ljharb I have a question, what are your thoughts on that feature?
@kimtaejin3 no feature was discussed; what are you referring to?
@ljharb Many people may wonder if we should put the value in the dependence list of useEffect even for the same value that always remains unchanged. So I hope that the corresponding rule of react-hooks has a feature to warn only functions that are likely to change. I wonder if the method of implementing this feature is expensive and cumbersome, and whether this function is worth adding. I am sorry that I may not be able to communicate well because my English is not good
@kimtaejin3 eslint-plugin-react-hooks is an entirely different package (one managed by the react team) than this one, eslint-plugin-react. Please file your issue on the react repo, not here.
Is there an existing issue for this?
Description Overview
ESLint version
8.57.0
What problem do you want to solve?
When i use react redux i have two problem
problem 1 Void function return value is used
in
routerAction.locationChange(route)
but actually
In this code I do not need return
so I want this fixed
problem 2 ESLint: React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array.(react-hooks/exhaustive-deps)
It can solve by put 'dispatch' inside [] but it is not needed
Redux's dispatch function is designed to have a constant reference throughout the app's life cycle. That is, even if a component is rerendered, the reference of the dispatch does not change. Therefore, you can prevent the hook from being unnecessarily re-executed without having to include the dispatch in the useEffect or useCallback dependency array.
So if (dependency is dispatch) {no warning plz} i hope there is extra rules for react users
What do you think is the correct solution?
no warning for theses two problem
Participation
Additional comments
No response
Expected Behavior
eslint-plugin-react version
7.34.1
eslint version
8.57.0
node version
20