Passionate with code... In love with Web Design, Videogames, Books and Jazz music.Years of experience in "document composition" and a Front-End Developer wannabe (since years)
Passionate with code... In love with Web Design, Videogames, Books and Jazz music.Years of experience in "document composition" and a Front-End Developer wannabe (since years)
In the valueChange function where did you find the state variable. May be it should be obj variable ?
In the second example?
The state is the obj variable.
You can see I’m creating an obj and using key-value pairs in It.
Then I’m passing the object to setState().
you defining
obj
, but then you usestate
. in non-strict mode this leads to the creation of a global variable, in strict mode this leads to an error.After that you use
obj
again, so the new value saved instate
in state isn't even used.Understood!