Log no. 2 - State, A Component's Memory - Part 2
Log no. 2 - State, A Component's Memory - Part 2 It is a learning day or "Spa Day" today and I am using it to make a big green dent (!) in my React docs reading list. So I am back to reading "State: A component's memory for now." Which explains state at a much deeper level So bro in a nutshell what have I learned or re-learned: The only argument that `useState` takes is the initial value of your new state variable For example if you were doing an counter you would start with `useState(0)` (if you wanted to start at zero) every time a component renders, `useState` give you an array containing two values the state variable with the value you stored the state setter function that can it can update the state variable more importantly, it can TRIGGER A RE-RENDER THE SYNTAX is something like `const [something, setSomething] = useState(initialValue)` Okay so that was the first part. So I read some more and made a great big diagram useState in Action So I highly...