DEV Community

Discussion on: The best Couple: useContext + useReducer !

Collapse
 
aoloo profile image
Allan Oloo • Edited

const contextValue = useMemo(() => {
return { counterCount: count, counterDispatch: dispatch };
}, [count, dispatch]);

In your step 2 I would possible memoize the values your passing to your provider for perfomance optimization. The object will always be recreated when the app component renders, which would cause all the children utilizing the context to re-render.