Reputation: 1475
I am trying to pass a variable to a prop function in React that is all within a .map function.
I am getting an Invalid Left-Hand Side in arrow function parameters error.
<div style={ style.navContainer }>
{navItems.map((item, i) => <div key={ i } onClick={ (item.name) => this.props.onClickGoTo(name) } style={ style.navItem }>
<img style={ style.icon } src={ item.src } />
{ item.name }</div>)}
</div>
Upvotes: 5
Views: 4475
Reputation: 5927
Almost. It should be:
onClick={ () => this.props.onClickGoTo(item.name) }
Upvotes: 11