Till innehållet
CTO Michel Zetterberg

React v16.6.0: lazy, memo and contextType

Innehåller ett par intressanta nyheter såsom PureComponent / shouldComponentUpdate för function components, code splitting med Suspense och ett enklare sätt att ta in Context från class-komponenter
1 oktober 2018
Dator på bord
Dator

React.memo is a higher order component. It’s similar to React.PureComponent but for function components instead of classes

React.lazy function lets you render a dynamic import as a regular component.

static contextType The contextType property on a class can be assigned a Context object created by React.createContext(). This lets you consume the nearest current value of that Context type using this.context. You can reference this in any of the lifecycle methods including the render function.

static getDerivedStateFromError() This lifecycle is invoked after an error has been thrown by a descendant component. It receives the error that was thrown as a parameter and should return a value to update state.

Hur kan vi hjälpa dig? Fyll i formuläret, mejla eller ring.

We ahead ABÅsögatan 119 Stockholm