Skip to content
Advertisement

Why my props action doesn’t work in an “if” statement in “onClick”, but it works outside the “if” statement?

This code works:

JavaScript

This code doesn’t work:

JavaScript

I’m new to reactjs Does any body know why it doesn’t work in the second way?

Advertisement

Answer

Just a tip; Make a function and then call the funciton onClick instead. The code gets simpler to read!

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement