question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react/jsx-no-bind false positive?

See original GitHub issue

Example snippet:

import React from 'react';
import PropTypes from 'prop-types';

class FalsePositive extends React.PureComponent {
  static propTypes = {
    list: PropTypes.arrayOf(PropTypes.node).isRequired,
  };

  render() {
    return (
      <div>
        {this.props.list.map(this.wrap.bind(this, 'span'))}
      </div>
    );
  }

  wrap(Tag, item, i) {
    return <Tag key={i}>{item}</Tag>;
  }
}

export default FalsePositive;

this.wrap.bind triggers the rule, even though the bound function isn’t the actual prop being passed, but is being used during the render to build the children, so it shouldn’t break purity.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jackyho112commented, Sep 19, 2017

@ljharb

Thanks for replying! I think I know the direction I’m going with to fix this issue now. Will open a PR soon. 😄

0reactions
ljharbcommented, Sep 19, 2017

It’s hard to evaluate without an actual PR; I’d love to look at the test case and docs changes in particular that you’re suggesting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

12 essential ESLint rules for React - LogRocket Blog
Introduction. ESLint has a comprehensive set of rules for JavaScript code that cover stylistic choices and prevent common bugs.
Read more >
Files changed (103) - Renovate Bot Package Diff
[`destructuring-assignment`]: fix a false positive for local prop named `context` in SFC ([#2929][] @SyMind). 85. - * [`jsx-no-target-blank`]: Allow ...
Read more >
eslint-config-canonical - npm
Rule CN AB GG SD XO @babel/new‑cap ❌ 👻 👻 👻 👻 @babel/no‑invalid‑this 🚨 👻 👻 👻 👻 @babel/no‑unused‑expressions 🚨 👻 👻 👻 👻
Read more >
SharePoint Framework (SPFx) v1.15 and the attack of ESLint!
lintCmd.enabled = false; // existing code... ... The react/jsx-no-bind rule states we shouldn't ever use arrow functions in our React ...
Read more >
eslint-plugin-react - npm Package Health Analysis - Snyk
We found that eslint-plugin-react demonstrates a positive version release cadence with at least one new version released in the past 3 months.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found