Skip to content

Commit

Permalink
docs(ComponentProps): replace deprecated lifecycle methods (#3555)
Browse files Browse the repository at this point in the history
  • Loading branch information
grumblerchester authored and layershifter committed Apr 8, 2019
1 parent cee78a5 commit 9d26779
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@ export default class ComponentProps extends Component {
displayName: PropTypes.string.isRequired,
}

state = {
activeDisplayName: null,
}

componentWillReceiveProps(nextProps) {
const currentName = this.props.displayName
const nextName = nextProps.displayName
state = {}

if (currentName.displayName !== nextName) {
this.setState({ activeDisplayName: null })
static getDerivedStateFromProps(props, state) {
return {
displayName: props.displayName,
activeDisplayName: props.displayName === state.displayName ? state.activeDisplayName : null,
}
}

Expand Down

0 comments on commit 9d26779

Please sign in to comment.