Skip to content

Unused var + linting #64

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

Closed
goldylucks opened this issue Apr 20, 2018 · 1 comment
Closed

Unused var + linting #64

goldylucks opened this issue Apr 20, 2018 · 1 comment

Comments

@goldylucks
Copy link

goldylucks commented Apr 20, 2018

Isn't passing value enough?

Here:
https://github.com/ReactTraining/react-workshop/blob/13748e43467581c2933dbd878f1cc1aef6a08263/subjects/07-Compound-Components/solution.js#L62-L66

Can do this instead:

  select(value) {
    this.setState({ value }, () => {
      this.props.onChange(value); // no need to do this.state.value
    });
  }

Also having eslint installed would have flagged that value as an unused param.

@mjackson
Copy link
Member

You can do either one. this.state.value makes it clear that we're grabbing the value from this.state after it has been updated.

The value param is used in the setState call, so it's not unused.

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

No branches or pull requests

2 participants