DEV Community

Discussion on: React useContext and useReducer Hooks.

Collapse
 
boywithsilverwings profile image
Agney Menon

While this is a bare state management mechanism, it is not a replacement for redux. Here all components subscribed to the context will rerender when any value in the context changes.

When you use redux, only the components subscribed to that particular state rerenders on state change - even though there is a single global store.

Collapse
 
ritikbanger profile image
Ritik Banger

What if the context api is used with reducer? more complex but interesting thing to do.

Collapse
 
korneldoe profile image
Kornel

Good point. Is there a way to use something to prevent the subscribed components to rerender if not needed? Thinking about something like memo where it does shallow comparison on props object?