React Context Performance

Опубликовано: 16 Июнь 2026
на канале: Josh Ribakoff
984
32

In React, context is the hot new way to manage your state. Unfortunately its very new & best practices have not yet emerged. In this video I describe how every context consumer re-renders even when unrelated parts of the context value have changed, and how to fix this

First I describe the basics of React context, and discuss how every context consumer re-renders / updates whenever the context value changes on the provider, and how to create a mapValueToProps function, similar to Redux's mapStateToProps, to slice off just a subset of the context value as your component's props. This allows wrapping it in React.memo so that it does not re-render each time there is a new value on the context provider!