LOGIN
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link
QUESTION
Open

Why is my click handler breaking?

<img onClick={e => {
   this.setState({
   liked: true,
   type: e.currentTarget.getAttribute("value")
   }).then(() => { submitLike() })
   }} value="A" src={Bolt} height="29" alt="bolt" />
Javascript
React.js
3 likes 
Like
Award Contribution
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link
Like
1 like 
Award Contribution
Steven Reubenstone
50
Community Expert
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
 · New YorkU.S.
Share
Report
Get Link

This article was correct. Guy was making same mistake. Have you include call back inside setState not after.

<img onClick={e => { this.setState({ liked: true, type: e.currentTarget.getAttribute("value") }, () =>
 { submitLike() }) }} value="A" src={Bolt} height="29" alt="bolt" />
Like
2 likes 
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
Chat with us!
Help
Write something before you submit it!
Photo updated
Request Sent!
Updated
Copied to Clipboard