Skip to content

'react/jsx-no-bind' doesn't recognise ternary conditions #1722

Closed
@gwenaellarmet

Description

@gwenaellarmet
render () {
  return (
     <MyComponent
       onValidate={this.isAdmin ? this.onValidateAdmin.bind(this) : this.onValidate.bind(this)}
       onRequestClose={this.onRequestClose.bind(this)}
       {...props}
    >
  )
}

In the code above, the rules 'react/jsx-no-bind' is marking onRequestClose as a warning but not onValidate, although it should in my opinion.

I'll open a PR fixing this bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@gwenaellarmet

        Issue actions

          'react/jsx-no-bind' doesn't recognise ternary conditions · Issue #1722 · jsx-eslint/eslint-plugin-react