Content-Length: 279689 | pFad | https://redirect.github.com/jsx-eslint/eslint-plugin-react/issues/1444

A0 Jsx no bind rule · Issue #1444 · jsx-eslint/eslint-plugin-react · GitHub
Skip to content

Jsx no bind rule #1444

@nitish24p

Description

@nitish24p

The no bind rule flags of the following jsx code.

renderButton(someParams){
  return(
    <ButtonComponent
      onClick={this.handleClick.bind(this, someParams)} // <- Error here
    >
      Submit
    </ButtonComponent>  
  )
}

How ever if i modify the same function

renderButton(someParams){
  const clickHandler = this.handleClick.bind(this, someParams);
  return(
    <ButtonComponent
      onClick={clickHandler}
    >
      Submit
    </ButtonComponent>  
  )
}

The error is not thrown, how ever effectively the same thing of creating a new function when the renderButton method is called takes place, only in the second case a separate variable has been assigned. But in terms of memory allocation a new function is being created in both cases and though the rule will give a sign off it'll still not impact performance.

Proposal
Modify the scope of the rule to see if bind is called within that function scope..

I may be completely wrong in some assumptions but would like a discussion here , if possible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://redirect.github.com/jsx-eslint/eslint-plugin-react/issues/1444

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy