I have the following code in a render function:
<table className="table table-bordered table-striped">
<ResultsTableHeader />
<tbody>
{results.map(result => (
<Result
key={result.get('id')}
deleteResult={this.props.destroyResult.bind(null, result.get('id'))}
{...result}
/>
))}
</tbody>
</table>
esling is complaining about react/jsx-no-bind
, so normally I would create a reference to the bound func in the constructor but this is different as it is a different function on each call from map.
The other answers (using
=>
) are probably incorrect. From the jsx-no-bind documention:So ESLint will complain with both
bind
&=>
(except if you setallowArrowFunctions: true
).The solution is to move the function call inside the component.
In the parent:
In the child: