Skip to content

Commit b824bd2

Browse files
committed
Added getSnapshotBeforeUpdate to the polyfill notes
1 parent 4610392 commit b824bd2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

content/blog/2018-03-27-update-on-async-rendering.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ The two lifecycles can be used together like this:
161161

162162
`embed:update-on-async-rendering/react-dom-properties-before-update-after.js`
163163

164+
> Note
165+
>
166+
> If you're writing a shared component, the [`react-lifecycles-compat`](https://github.com/reactjs/react-lifecycles-compat) polyfill enables the new `getSnapshotBeforeUpdate` lifecycle to be used with older versions of React as well. [Learn more about how to use it below.](#open-source-project-maintainers)
167+
164168
## Other scenarios
165169

166170
While we tried to cover the most common use cases in this post, we recognize that we might have missed some of them. If you are using `componentWillMount`, `componentWillUpdate`, or `componentWillReceiveProps` in ways that aren't covered by this blog post, and aren't sure how to migrate off these legacy lifecycles, please [file a new issue against our documentation](https://github.com/reactjs/reactjs.org/issues/new) with your code examples and as much background information as you can provide. We will update this document with new alternative patterns as they come up.
@@ -171,7 +175,7 @@ Open source maintainers might be wondering what these changes mean for shared co
171175

172176
Fortunately, you do not!
173177

174-
When React 16.3 is published, we'll also publish a new npm package, [`react-lifecycles-compat`](https://github.com/reactjs/react-lifecycles-compat). This package polyfills components so that the new `getDerivedStateFromProps` lifecycle will also work with older versions of React (0.14.9+).
178+
When React 16.3 is published, we'll also publish a new npm package, [`react-lifecycles-compat`](https://github.com/reactjs/react-lifecycles-compat). This package polyfills components so that the new `getDerivedStateFromProps` and `getSnapshotBeforeUpdate` lifecycles will also work with older versions of React (0.14.9+).
175179

176180
To use this polyfill, first add it as a dependency to your library:
177181

@@ -183,7 +187,7 @@ yarn add react-lifecycles-compat
183187
npm install react-lifecycles-compat --save
184188
```
185189

186-
Next, update your components to use the new static lifecycle, `getDerivedStateFromProps`, as described above.
190+
Next, update your components to use the new lifecycles (as described above).
187191

188192
Lastly, use the polyfill to make your component backwards compatible with older versions of React:
189193
`embed:update-on-async-rendering/using-react-lifecycles-compat.js`

0 commit comments

Comments
 (0)