Skip to content

React lifecycle method warnings #49

@denis-sokolov

Description

@denis-sokolov

React deprecates componentWillReceiveProps in favor of getDerivedStateFromProps. Documentation. If we don’t fix this, the component will be broken in React 17.

componentWillReceiveProps(nextProps) {
if (nextProps.src !== this.props.src) {
this.isLoaded = false;
if (nextProps.initialImage) {
this.handleInitialTimeout();
}
this.setDisplayImage({ image: nextProps.src, fallbacks: nextProps.fallbackImage });
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions