Skip to content

Commit db71d03

Browse files
authored
Merge pull request #910 from bvaughn/rename-gdsfp-params
Renamed gDSFP params
2 parents ee4c4fa + 3e80980 commit db71d03

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

content/docs/reference-react-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ If you "fork" props by using them for state, you might also want to implement [`
186186
### `static getDerivedStateFromProps()`
187187

188188
```js
189-
static getDerivedStateFromProps(nextProps, prevState)
189+
static getDerivedStateFromProps(props, state)
190190
```
191191

192192
`getDerivedStateFromProps` is invoked right before calling the render method, both on the initial mount and on subsequent updates. It should return an object to update the state, or null to update nothing.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Example extends React.Component {
2-
static getDerivedStateFromProps(nextProps, prevState) {
2+
static getDerivedStateFromProps(props, state) {
33
// ...
44
}
55
}

examples/update-on-async-rendering/updating-external-data-when-props-change-after.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ class ExampleComponent extends React.Component {
55
};
66

77
// highlight-range{1-13}
8-
static getDerivedStateFromProps(nextProps, prevState) {
8+
static getDerivedStateFromProps(props, state) {
99
// Store prevId in state so we can compare when props change.
1010
// Clear out previously-loaded data (so we don't render stale stuff).
11-
if (nextProps.id !== prevState.prevId) {
11+
if (props.id !== state.prevId) {
1212
return {
1313
externalData: null,
14-
prevId: nextProps.id,
14+
prevId: props.id,
1515
};
1616
}
1717

examples/update-on-async-rendering/updating-state-from-props-after.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ class ExampleComponent extends React.Component {
88
lastRow: null,
99
};
1010

11-
// highlight-range{1-8}
12-
static getDerivedStateFromProps(nextProps, prevState) {
13-
if (nextProps.currentRow !== prevState.lastRow) {
11+
// highlight-range{1-7}
12+
static getDerivedStateFromProps(props, state) {
13+
if (props.currentRow !== state.lastRow) {
1414
return {
15-
isScrollingDown:
16-
nextProps.currentRow > prevState.lastRow,
17-
lastRow: nextProps.currentRow,
15+
isScrollingDown: props.currentRow > state.lastRow,
16+
lastRow: props.currentRow,
1817
};
1918
}
2019

examples/update-on-async-rendering/using-react-lifecycles-compat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {polyfill} from 'react-lifecycles-compat';
44

55
class ExampleComponent extends React.Component {
66
// highlight-next-line
7-
static getDerivedStateFromProps(nextProps, prevState) {
7+
static getDerivedStateFromProps(props, state) {
88
// Your state update logic here ...
99
}
1010
}

0 commit comments

Comments
 (0)