Skip to content

Avoid using deprecated/UNSAFE_* React methods #519

@BPScott

Description

@BPScott

React has deprecated its use of a selection of lifecycle methods it has deemed to be unsafe.

The componentWillMount, componentWillReceiveProps and componentWillUpdate lifecycle methods have the potential to cause headaches and We should use the newer, more stable lifecycle methods of getDerivedStateFromProps and getSnapshotBeforeUpdate instead.

We could shuffle onto using UNSAFE_componentWillMount etc but that doesn't fix the root problem.

The good news is ESLint now warns about our usage of these methods so we no longer have to think about this when doing PR reviews, however there are still a few places in existing code where they are used. Any existing use of these functions should be removed


Search the codebase for react/no-deprecated and refactor the usage of the componentWillMount, componentWillReceiveProps and componentWillUpdate to use the new lifecycle functions.

As of 2018-10-04, searching the codebase for react/no-deprecated shows the following Components are affected:

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions