Derived State In React

TopicSource
๐Ÿงฉ ReactReact - Udemy

If you have a variable that is dependent on another state variable, you don't need to create another state variable for this. It is sufficient, to create a normal local variable let or const for this.

The whole function component gets re-rendered anyway, when the state gets updated, so the local variable will get computed again as well.


  1. Lifting the state up
  2. React state does not update immediately - use useEffect to work with the new value