eslint-plugin-react-hooks does not work with wrapped components
See original GitHub issueexport const Counter = () => {
let count, setCount;
if (0 === 1) {
[count, setCount] = useState(0);
}
return count;
};
const wrapper = Component => Component;
export const WrappedCounter = wrapper(() => {
let count, setCount;
if (0 === 1) {
[count, setCount] = useState(0);
}
return count;
});
Linter shows an error in the first component, but ignore the second one.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Rules of Hooks - React
Only Call Hooks from React Functions By following this rule, you ensure that all stateful logic in a component is clearly visible from...
Read more >12 essential ESLint rules for React - LogRocket Blog
This plugin only contains two rules, but they are critical to avoiding common pitfalls when writing function components with Hooks.
Read more >eslint-plugin-react - npm
Start using eslint-plugin-react in your project by running `npm i ... If this isn't set, any propTypes wrapped in a function will be...
Read more >eslint-plugin-react-hooks shows incorrect "missing dependency"
Show activity on this post. Assume you are using React and you are writing a custom hook useSomething that returns the identical same...
Read more >eslint-plugin-react-hooks | Yarn - Package Manager
React is a JavaScript library for building user interfaces. ... and React will efficiently update and render just the right components when your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Another interesting case that triggers this is using the built-in
React.memo
function:(We fixed the case for memo/forwardRef)