Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

refactor all "UNSAFE_" calls to newer react lifecycle calls #1940

Open
cindyloo opened this issue Jul 17, 2020 · 6 comments
Open

refactor all "UNSAFE_" calls to newer react lifecycle calls #1940

cindyloo opened this issue Jul 17, 2020 · 6 comments

Comments

@cindyloo
Copy link
Contributor

No description provided.

@dsjen dsjen added this to the v3.16.x - Partisanship milestone Jul 22, 2020
@cindyloo
Copy link
Contributor Author

cindyloo commented Aug 5, 2020

the following are deprecated:
componentWillMount
componentWillRecieveProps
componentWillUpdate

according to this link
we should implement
componentWillReceiveProps -> getDerivedStateFromProps

componentWillUpdate -> getSnapshotBeforeUpdate
getSnapshotBeforeUpdate handles what componentWillUpdate and componentDidUpdate would have done just before the DOM gets updated.

componentWillMount -> componentDidMount

this affect 36 matches across 27 files. Do we feel it is necessary at this point to do? When we move to React v17, it will be....

@rahulbot
Copy link
Contributor

rahulbot commented Aug 5, 2020

When that deprecation got release, I ran the script that marked them all as UNSAFE_. At that point I was daunted by refactoring to fix all of them, because we had ongoing features in development. It is technical debt we will have to pay in order to keep up with React updates soon, lest we fall behind like we have with react-router (#562). When to pay it is the tricky question.

@dsjen
Copy link
Contributor

dsjen commented Aug 10, 2020

Thanks for digging up info on how to do it and I agree that it's a big endeavor. We don't have to tackle this all at once and can pick a file at a time. I bet once we establish a pattern the task will be less daunting, and we can divide and conquer.

@cindyloo
Copy link
Contributor Author

I propose sectioning off
first:
common/ && common/mediapicker (10 files or so)
in tandem or one then the other:
sources && explorer (10 files or so)
topics (13 files or so)

cindyloo pushed a commit that referenced this issue Aug 10, 2020
@cindyloo
Copy link
Contributor Author

I found this article very helpful for refactoring https://itnext.io/react17-or-how-to-get-rid-of-componentwillreceiveprops-c91f9a6f6f03

cindyloo pushed a commit that referenced this issue Aug 25, 2020
cindyloo pushed a commit that referenced this issue Aug 26, 2020
cindyloo pushed a commit that referenced this issue Aug 26, 2020
cindyloo pushed a commit that referenced this issue Sep 2, 2020
@cindyloo
Copy link
Contributor Author

cindyloo commented Sep 2, 2020

mediapicker, topics, explorer now refactored and spot tested. sources will be the last section

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants