Skip to content

Commit bf504d3

Browse files
grumblerchesterlayershifter
authored andcommitted
docs(ComponentDoc): replace deprecated lifecycle methods (#3535)
* docs(ComponentDoc): replace deprecated lifecycle methods Replace componentWillReceiveProps by getDerivedStateFromProps. * Update ComponentDoc.js
1 parent ffa41bf commit bf504d3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docs/src/components/ComponentDoc/ComponentDoc.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ class ComponentDoc extends Component {
3434
state = {}
3535
examplesRef = createRef()
3636

37-
getChildContext() {
37+
static getDerivedStateFromProps(props, state) {
3838
return {
39-
onPassed: this.handleExamplePassed,
39+
displayName: props.displayName,
40+
activePath: props.displayName === state.displayName ? state.activePath : undefined,
4041
}
4142
}
4243

43-
componentWillReceiveProps({ displayName }) {
44-
if (displayName !== this.props.displayName) {
45-
this.setState({ activePath: undefined })
44+
getChildContext() {
45+
return {
46+
onPassed: this.handleExamplePassed,
4647
}
4748
}
4849

0 commit comments

Comments
 (0)