Please enable JavaScript.
Coggle requires JavaScript to display documents.
React State Hook (hook (React uses a lot of hooks (useState(stateObj,…
React State Hook
hook
is a collection of functions
starts with "use..." keyword
React uses a lot of hooks
useState(stateObj, function)
most important react hook
allows to manage the state in a functional component
returns exact 2 elements
current state
function
allows state manipulation
state object will be
overwritten
, not merged :fire:
call this state function to change and rerender
like setState in Class Components
can used multiple times in a component
for multiple state objects
difference to state in class component :pencil2:
class component uses one big state object to handle all states
state for functional components
before React 16.8 not possible
no need for class component
since React 16.8