Files
react.dev/examples/update-on-async-rendering/using-react-lifecycles-compat.js
2018-02-07 09:21:38 -08:00

17 lines
428 B
JavaScript

import React from 'react';
// highlight-next-line
import polyfill from 'react-lifecycles-compat';
class ExampleComponent extends React.Component {
// highlight-next-line
static getDerivedStateFromProps(nextProps, prevState) {
// Your state update logic here ...
}
}
// Polyfill your component to work with older versions of React:
// highlight-next-line
polyfill(ExampleComponent);
export default ExampleComponent;