DEV Community

Discussion on: State and setState Explained with Emotion

Collapse
walliskasswin profile image
Walliskasswin

Great article. There are some typos though.
A function that updates a state cannot be invoked inside of the render function or in the return block of a functional component, it will lead to infinite re-renders. You should instead pass the reference of the function.
So it is onClick={handleMeditation} instead of onClick={handleMeditation()}.

Also when passing props to functional components, to specify each props name you need to destructure.
So it's const Toddler=({handleTemperTantrum, emotion})=>{} instead of const Toddler=(handleTemperTantrum, emotion)=>{}

Collapse
shaundai profile image
Shaundai Person Author

Great catches! Normally I do a better job proofreading these before publishing :D fixed - thank you!