Skip to content

no-unused-state rule doesn't handle dynamic keys #1361

Closed
@EvHaus

Description

@wbinnssmith The following code:

_handleUpdate = (stateName, active) => {
	this.setState({[stateName]: active});
};

Gives out an Unused state field: 'stateName' error from the no-unused-state rule.

I think it's probably best to have no-unused-state rule ignore dynamic object keys since it will be too difficult to detect whether or not they're really being used. But at the very least, it shouldn't use the variable name as the key to look for.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions