Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove all deprecated React lifecycle methods #17432

Closed
1 of 7 tasks
timroes opened this issue Mar 28, 2018 · 3 comments
Closed
1 of 7 tasks

Remove all deprecated React lifecycle methods #17432

timroes opened this issue Mar 28, 2018 · 3 comments
Labels
chore Meta stale Used to mark issues that were closed for being stale Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@timroes
Copy link
Contributor

timroes commented Mar 28, 2018

Summary

React will introduce async rendering and deprecate some lifecycle methods in the upcoming 16.x versions, since they are replaced with new lifecycle methods. Since these lifecycle methods, will be removed with React 17.0, we'll need to remove all of the deprecated lifecycle methods, before we update to React 17.0 in the future. This is the meta ticket, to remind us to remove all of those lifecycle methods.

The following lifecycle methods will be removed in the future:

  • componentWillUpdate
  • componentWillReceiveProps
  • componentWillMount

Most of the use-cases of these lifecycle methods can be solved with some other life-cycle method or one of the two new methods:

  • static getDerivedStateFromProps
  • getSnapshotBeforeUpdate

More resources

A detailed explanation of the migration with a lot of use-case examples can be found in Facebook's blog post. Since the blog post doesn't have a table of content, here are a list of possible use-cases that used the deprecated lifecycle methods:

Another resource, but not providing any more information than the above blog post, is the React 16.3 release blog post.

To be refactored

All of the following features are currently using componentWillMount and/or componentWillReceiveProps and should thus be refactored before React 17 or replaced completely (like Kibana UI framework).

  • Kibana Home
  • Kibana UI Framework
  • Dashboard Components & Grid
  • Index Pattern Wizard / Edit Index Patterns
  • TSVB
  • Input Control Vis
  • Markdown Vis
@w33ble
Copy link
Contributor

w33ble commented Mar 30, 2018

16.3.0 was released yesterday: https://github.com/facebook/react/releases/tag/v16.3.0

@w33ble w33ble added Team:Operations Team label for Operations Team and removed blocked labels Mar 30, 2018
@w33ble
Copy link
Contributor

w33ble commented Apr 5, 2018

There's an open issue in eslint-plugin-react about removing a couple of the recommended rules, see jsx-eslint/eslint-plugin-react#1754. From the author:

"componentWillMount", "componentWillUpdate", "componentWillReceiveProps" will be deprecated life-cycle methods (React 16.3.0, introduced these and deprecation warnings are scheduled to come with 16.4.0), and replacements for those will be accordingly "componentWillMount" => "componentDidMount", "componentWillUpdate"  => "componentDidUpdate" and "componentWillReceiveProps" => with new introduced "getDerivedStateFromProps".

Therefore it's not relevant to have this rule and existing code bases should be migrated soon enough to match new life-cycles.

We may consider removing those rules from eslint-config-kibana as well, unless we find that it's something we want to explicitly add exceptions to in the code as needed.

@jbudz jbudz added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc and removed Team:Operations Team label for Operations Team labels Apr 25, 2018
@kertal
Copy link
Member

kertal commented Nov 27, 2019

We're moving to React 16.12, there will be lots of deprecation warnings, after #51145 will be merged. There will be a follow up PR with a codemod, but that will just rename the functions to remove the warnings. So we should refactor code to remove those deprecated functions

@joshdover joshdover added the stale Used to mark issues that were closed for being stale label Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Meta stale Used to mark issues that were closed for being stale Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
None yet
Development

No branches or pull requests

5 participants