Closed
Description
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
}
}
Metadata
Metadata
Assignees
Labels
No labels