React state comparison: class vs function
Mar 20, 2021
Class
Rendering initial state:
Updating state:
Class state
property must be an object since setState
takes an object of state variables to update.
Function
Rendering initial state:
Updating state:
There can be multiple useState
hooks in a function.
The initial state passed to useState
doesn’t have to be an object: