r/reactjs • u/acemarke • Mar 02 '18
Beginner's Thread / Easy Questions (March 2018)
Last month's thread was pretty busy - almost 200 comments . If you didn't get a response there, please ask again here!
Soo... Got questions about React or anything else in its ecosystem? Stuck making progress on your app? Ask away! We’re a friendly bunch. No question is too simple.
The Reactiflux chat channels on Discord are another great place to ask for help as well.
27
Upvotes
View all comments
Show parent comment
2
u/markm247 Mar 24 '18
Change your click handler to accept an index parameter:
clickHandler = (index) => { console.log(this.state.currentHand[index]); }and change your currentHand.map call to include the index as a parameter for the click handler:
const myHand = this.state.currentHand.map((currentHand, index) => { return <div onClick={() =>this.clickHandler(index)}> card {currentHand} </div> })