Skip to content

react/jsx-no-bind false positive? #1417

Closed
@bcutler-work

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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