Skip to content

react/no-string-refs recommendations conflict with no-return-assign #980

@ryankask

Description

@ryankask

I've just upgraded to the latest version and one of issues the came up was with react/no-string-refs.

The docs here suggest the following:

<Foo
  ref={(ref) => this.myRef = ref}
/>

This causes a no-return-assign error. I'm not sure if it's possible but should this rule be relaxed in this case?

One way around it is wrapping the assignment in parenthesis:

<Foo
  ref={ref => (this.myRef = ref)}
/>

But that seems a bit off. Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions