LOGIN
Steven Reubenstone
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
Steven Reubenstone
51
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
· New York, NY, USA
QUESTION

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
Software
Web Development
Front End Development
Skills
React.js
3 likes
Like
Award Contribution
Steven Reubenstone
51
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
· New York, NY, USA
Like
1 like
Award Contribution
Steven Reubenstone
51
Mechanical Engineer & Tinkerer of Things. Collaborizm Roundtable.
· New York, NY, USA

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