-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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]: Rule: "react/no-unused-state": TypeError: Cannot read properties of undefined (reading 'references') #3568
Labels
Comments
Although lifecycles should always be a method and never a class field, it shouldn't crash regardless, so I'll have a fix pushed up shortly. |
ljharb
added a commit
to ljharb/eslint-plugin-react
that referenced
this issue
May 1, 2023
…h destructured state Fixes jsx-eslint#3568
1 task
This was referenced May 24, 2024
This was referenced Jun 18, 2024
This was referenced Aug 22, 2024
This was referenced Sep 24, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there an existing issue for this?
Description Overview
When the prev state parameter (second parameter) of
getDerivedStateFromProps
is destructured in-place, the rulereact/no-unused-state
crashesstatic getDerivedStateFromProps = ({value, disableAnimation}: ToggleProps, {isControlled, isOn}: ToggleState) => {
here,
isControlled
andisOn
are destructured state properties.Expected Behavior
The eslint rule should handle the code without crashing.
The issue seems to be that the stateArg.name on the line below is undefined whereas it is expected to be 'state' or some other name if destructuring is not used.
eslint-plugin-react version
7.32.2
eslint version
8.2.0
node version
18.12.1
The text was updated successfully, but these errors were encountered: