In this post, we will see how to resolve Variable and input variable React
Question:
Why won’t this code which causes a variable called age to increase or decrease according to the pressing of certain buttons. But then it should also allow us see whatever is typed in the text box be displayed outside of it.App.js
Best Answer:
The problem is that you can’t mutate the state in React. So you can’t have it like this:It is really common mistake, you can read more about this issue on this blog post: https://www.joshwcomeau.com/react/common-beginner-mistakes/#mutating-state-2
I generally recommend to follow Josh for React knowledge.
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com