Skip to content

Tag: reactjs

setState callback not waiting state to update

I have this piece of code: Im calling this function on this piece of code: The things is im getting: TypeError: Cannot read property ‘value’ of undefined It’s saying the problem is in this line: maxLevel: event.target.value. I dont get it, isnt the callback supposed to wait for the first set…

Separate onClick event for parent and child element

I have JSX code like this: When I click on parent (outside the child) it will run clickOnParent, and when I click the child it will run both clickOnParent and clickOnChild of course.Now I want to trigger only clickOnChild and ignore clickOnParent when clicking exactly on the child. How can I do? Answer Use Ev…