Skip to content
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

prefer-stateless-function should detect null in if shorthand return #516

Closed
inyono opened this issue Mar 28, 2016 · 0 comments
Closed

prefer-stateless-function should detect null in if shorthand return #516

inyono opened this issue Mar 28, 2016 · 0 comments

Comments

@inyono
Copy link
Contributor

inyono commented Mar 28, 2016

With enabled rule prefer-stateless-function, the following does throw a warning although null may be returned:

class If extends Component {
  render() {
    const { condition, ...props } = this.props

    return condition ? <this.props.component {...props} /> : null
  }
}

If we write the result to a variable, though, there is no warning:

class If extends Component {
  render() {
    const { condition, ...props } = this.props

    const component = condition ? <this.props.component {...props} /> : null

    return component
  }
}
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

1 participant