In this lesson we'll take an existing class component and refactor it to use the useState React Hook. We'll see what changes between class and function components and also how to use the useState method.
Good point, Luca, const
will be more technically correct and will communicate your intentions better to fellow programmers, since state will not change during each render. Even with the useRef
hook which communicates imperative, mutable code, usually the common usage is still const
, although sometimes you'll see a let
. Thanks for pointing this out!
Why using
let
instead ofconst
withuseState
? It shouldn't be more correct havingconst
in order to show that we shouldn't touch those variables?