React Context Performance

Pubblicato il: 17 maggio 2019
sul canale di: 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!


In questa pagina del sito puoi guardare il video online React Context Performance della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Josh Ribakoff 17 maggio 2019, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 984 volte e gli è piaciuto 32 spettatori. Buona visione!