Skip to content

Commit 9d26779

Browse files
grumblerchesterlayershifter
authored andcommitted
docs(ComponentProps): replace deprecated lifecycle methods (#3555)
1 parent cee78a5 commit 9d26779

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

docs/src/components/ComponentDoc/ComponentProps/ComponentProps.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ export default class ComponentProps extends Component {
1616
displayName: PropTypes.string.isRequired,
1717
}
1818

19-
state = {
20-
activeDisplayName: null,
21-
}
22-
23-
componentWillReceiveProps(nextProps) {
24-
const currentName = this.props.displayName
25-
const nextName = nextProps.displayName
19+
state = {}
2620

27-
if (currentName.displayName !== nextName) {
28-
this.setState({ activeDisplayName: null })
21+
static getDerivedStateFromProps(props, state) {
22+
return {
23+
displayName: props.displayName,
24+
activeDisplayName: props.displayName === state.displayName ? state.activeDisplayName : null,
2925
}
3026
}
3127

0 commit comments

Comments
 (0)