Skip to content

Commit 5775f07

Browse files
andrewigginsgaearon
authored andcommitted
Add signature to getSnapshotBeforeUpdate section (reactjs#1032)
Add the signature for `getSnapshotBeforeUpdate` to its section, just like all other lifecycle method sections have.
1 parent f5d6818 commit 5775f07

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

content/docs/reference-react-component.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ Note that this method is fired on *every* render, regardless of the cause. This
293293

294294
### `getSnapshotBeforeUpdate()`
295295

296+
```javascript
297+
getSnapshotBeforeUpdate(prevProps, prevState)
298+
```
299+
296300
`getSnapshotBeforeUpdate()` is invoked right before the most recently rendered output is committed to e.g. the DOM. It enables your component to capture some information from the DOM (e.g. scroll position) before it is potentially changed. Any value returned by this lifecycle will be passed as a parameter to `componentDidUpdate()`.
297301

298302
This use case is not common, but it may occur in UIs like a chat thread that need to handle scroll position in a special way.

0 commit comments

Comments
 (0)