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!
Auf dieser Seite können Sie das Online-Video React Context Performance mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Josh Ribakoff 17 Mai 2019 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 984 Mal angesehen und es wurde von 32 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!