Fullstack React: Props are like component arguments
|
|
Now that we have the
We'll need a way to update the time in our
Let's set this up so that we have a timer that fires in one second and updates the
Checkout the complete, runnable example in jsbin here. In 1000 milliseconds (1 second), our timeout will fire, which in turn calls We'll want to make sure the timeout gets fired on an interval, so every second the state is updated. The
That's it. Now we have a fully stateful component which we can use inside the Now, that we have walked through Cheers! Ari P.S. A lot of folks ask, "what if I need to use the current state in the calculation for the next state?" In that case, you need to use a special form of setState -- we talk about it in our book. |
|
|
|
If you no longer wish to receive our emails, click the link below:
Unsubscribe