Skip to content

Commit

Permalink
docs(ComponentDoc): replace deprecated lifecycle methods (#3535)
Browse files Browse the repository at this point in the history
* docs(ComponentDoc): replace deprecated lifecycle methods

Replace componentWillReceiveProps by getDerivedStateFromProps.

* Update ComponentDoc.js
  • Loading branch information
grumblerchester authored and layershifter committed Mar 28, 2019
1 parent ffa41bf commit bf504d3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/src/components/ComponentDoc/ComponentDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ class ComponentDoc extends Component {
state = {}
examplesRef = createRef()

getChildContext() {
static getDerivedStateFromProps(props, state) {
return {
onPassed: this.handleExamplePassed,
displayName: props.displayName,
activePath: props.displayName === state.displayName ? state.activePath : undefined,
}
}

componentWillReceiveProps({ displayName }) {
if (displayName !== this.props.displayName) {
this.setState({ activePath: undefined })
getChildContext() {
return {
onPassed: this.handleExamplePassed,
}
}

Expand Down

0 comments on commit bf504d3

Please sign in to comment.