Open Bug 1508688 Opened 2 years ago Updated 1 year ago

Remove deprecated React lifecycle methods

Categories

(DevTools :: about:debugging, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: ladybenko, Unassigned)

References

(Blocks 1 open bug)

Details

Some React component lifecycle methods are going to be removed from React 17
https://hackernoon.com/problematic-react-lifecycle-methods-are-going-away-in-react-17-4216acc7d58b

We should make sure our code doesn't use them (currently the patch on https://bugzilla.mozilla.org/show_bug.cgi?id=1479746 uses `componentWillMount`).

We should also introduce a linter rule to avoid using these in the future (see https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md).
As a note, on React 17 these methods will still exist, but with a `UNSAFE_` prefix.

(In reply to Belén [:ladybenko] from comment #1)

As a note, on React 17 these methods will still exist, but with a UNSAFE_
prefix.

Actually, they will be removed in 17.0... here is the migration path:

  • 16.3: Introduce aliases for the unsafe lifecycles, UNSAFE_componentWillMount, UNSAFE_componentWillReceiveProps, and UNSAFE_componentWillUpdate. (Both the old lifecycle names and the new aliases will work in this release.)
  • A future 16.x release: Enable deprecation warning for componentWillMount, componentWillReceiveProps, and componentWillUpdate. (Both the old lifecycle names and the new aliases will work in this release, but the old names will log a DEV-mode warning.)
  • 17.0: Remove componentWillMount, componentWillReceiveProps, and componentWillUpdate . (Only the new “UNSAFE_” lifecycle names will work from this point forward.)

As you say in the last bullet point Only the new “UNSAFE_” lifecycle names will work from this point forward. So that's the same as what :ladybenko said in comment #1

Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.