mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Add signature to getSnapshotBeforeUpdate section (#1032)
Add the signature for `getSnapshotBeforeUpdate` to its section, just like all other lifecycle method sections have.
This commit is contained in:
committed by
Dan Abramov
parent
f5d6818660
commit
5775f070e2
@@ -293,6 +293,10 @@ Note that this method is fired on *every* render, regardless of the cause. This
|
||||
|
||||
### `getSnapshotBeforeUpdate()`
|
||||
|
||||
```javascript
|
||||
getSnapshotBeforeUpdate(prevProps, prevState)
|
||||
```
|
||||
|
||||
`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()`.
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user