Description
I want to report a bug for the hooks plugin.
What is the current behavior?
There was no error report after running eslint, but the component failed when running in the browser.
From the chrome dev console it reported "Uncaught Error: Rendered fewer hooks than expected. This may be caused by an accidental early return statement."
**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React.
Here is a link to the github repo:
https://github.com/paboulos/react-hooks-eslint
What is the expected behavior?
Followed The Hooks API guide which says React hooks provides a linter plugin to enforce these rules automatically.Therefore it should have reported a usage violation when the eslint hooks plugin is specified.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Using window 10 OS and Chrome browser.
- First ran npx create-react-app Hooks
- Installed react 16.7.0-alpha.2 and react-dom 16.7.0-alpha.2
- Installed eslint dev dependencies:
"babel-eslint": "9.0.0",
"babel-loader": "8.0.4",
"eslint": "5.9.0",
"eslint-config-airbnb": "17.1.0",
"eslint-loader": "2.1.1",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-react": "7.11.1",
"eslint-plugin-react-hooks": "0.0.0" - Created the .eslintrc.json following the instructions from the Hooks API Doc
Then ran package script lint as follows: "npm run lint"
no errors reported.
Then ran package script start as follows: "npm start"
The React component CountHooks calls useState incorrectly and reports error in the browser dev console.
Activity