Pattern: Inline function creation in JSX props
Issue: -
Using locally defined functions as prop values leads to unnecessary re-renders since a new function instance is created on each parent render. This causes child components to re-render and makes props harder to maintain consistently.
Example of incorrect code:
<Item callback={new Function(...)} />
<Item callback={this.props.callback || function() {}} />
Example of correct code:
<Item callback={this.props.callback} />