DEV Community

Discussion on: React Context API + useReducer() = Redux

Collapse
 
theluk profile image
Lukas Klinzing

If you have as many actions as usually you have in redux this might get quite expensive as every change will recreate all those actions and all components that depend on any of the action or any of the state. That is a fundamental difference between redux and context. Redux handles memoization well and selects only what you need. Also you create actions only once and not multiple times. So because the dispatch function never changes, so should also the actions never change.

Collapse
 
kambleaa007 profile image
Ashish Kamble

so what will be better efficient way of using context in enterprise projects

Collapse
 
burhanuday profile image
Burhanuddin Udaipurwala

Use it for state that does not change often - stuff like theme preference, language preference. Context is not a state management solution, it's a dependency injection mechanism