Skip to content

Warning about componentWillReceiveProps in React's Strict Mode #624

Open
@ulrichb

Description

@ulrichb

React's Strict Mode warns about "Unsafe lifecycle methods were found within a strict-mode tree".

componentWillReceiveProps: Please update the following components to use static getDerivedStateFromProps instead.

componentWillReceiveProps(nextProps) {
if (shallowEqualArrays(nextProps.suggestions, this.props.suggestions)) {
if (
nextProps.highlightFirstSuggestion &&
nextProps.suggestions.length > 0 &&
this.justPressedUpDown === false &&
this.justMouseEntered === false
) {
this.highlightFirstSuggestion();
}
} else {
if (this.willRenderSuggestions(nextProps)) {
if (this.state.isCollapsed && !this.justSelectedSuggestion) {
this.revealSuggestions();
}
} else {
this.resetHighlightedSuggestion();
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions