-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: eslint-plugin-react-hooks: Cannot read property 'references' of undefined #19043
Comments
I can't reproduce this error. Using the code example you pasted above: const onSave = useCallback(
args => {
const request: CreateMonitorV3Request = {
programUuid: program?.uuid ?? '',
};
monitorService
.create(request)
.then(x => {
// $FlowFixMe - program will be available
navigate(`/programs/${program.slug}/monitors/${x.uuid}`);
})
.catch(ex => {
console.log('error', ex);
});
},
[monitorService, program?.uuid]
); I see:
This is using both eslint-plugin-react-hooks@1.7.0 which is the version create-react-app installs and the latest version (v4.0.4) which I pulled in using a resolution: "resolutions": {
"react-scripts/eslint-plugin-react-hooks": "^4.0.4"
}, |
Which Node version are you using? (I'm using v12.16.2 and I also tested v10.20.1 without problem.) |
My guess is that its a mismatch between the flow and react-hooks linter. in this instance The issue probably comes down to the fact that I'm referencing In my case I know for fact that Also, if I change the |
from looking at your code example, you should have |
Ya, my dependencies were incorrect, however ideally there shouldn't be an exception when identify the missing dependencies. |
Agreed, I could see some similar code used for |
I'm also getting this. |
The suggested edit I made on PR #19062 (comment) will fix this issue. |
@bvaughn hey, not sure if labels matter or who takes care of them, but this looks like it has a PR open to address it, so it would be |
I have this issue too on eslint-plugin-react-hooks@4.0.5 |
PR #19062 was supposed to fix this issue. It was merged and released in 4.0.5 but the issue was accidentally left open. If folks are seeing a similar bug, please file a new issue with repro information. I'm going to close this one. |
eslint-plugin-react-hooks is throwing a
Cannot read property 'references' of undefined
error on/node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js:1683:23
I added a console log statement before that line
and this is the output.
I don't actually have
program?.slug
referenced anywhere in this file.I am using
program.slug
though.Versions:
eslint-plugin-react-hooks@4.0.4
eslint@6.8.0
babel-eslint@10.1.0
Steps To Reproduce
The code below throws the error.
I have found 2 ways to stop the error from happening.
programUuid: program?.uuid ?? '',
program.slug
to the list of dependencies.Link to code example:
The current behavior
Error is thrown
Cannot read property 'references' of undefined
The expected behavior
eslint successfully reports that I'm missing dependencies in
useCallback
Full Stack trace:
The text was updated successfully, but these errors were encountered: