DEV Community

Discussion on: We don't know how React state hook works

Collapse
 
adamklein profile image
adam klein

Hi, glad to hear!
useReducer is a local state hook: reactjs.org/docs/hooks-reference.h...
Redux is not part of React, it's a 3rd party library that manages global state
There are a lot of similarities because both of them update state using a reducer and dispatching actions.

If basicStateReducer receives a value that is not a function, it sets it as the new state.

So imagine a reducer that looks like this for plain values: (state, action) => action