Till innehållet
Till startsidan
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.

Behöver ni ett starkt webbteam redan idag?

Prata med Axel, vår konsultchef, ring honom på +46703557355 eller mejla axel@weahead.se

Axel F