Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

fix warning at #2680 #2681

Open
icecream17 wants to merge 3 commits into atom:master
base: master
Choose a base branch
Loading
from icecream17:fix-warning
Open

fix warning at #2680 #2681

icecream17 wants to merge 3 commits into atom:master from icecream17:fix-warning

Conversation

@icecream17
Copy link

@icecream17 icecream17 commented May 14, 2021
edited
Loading

Please be sure to read the contributor's guide to the GitHub package before submitting any pull requests.

Description of the Change

componentWillRecieveProps is now deprecated, so this pr replaces it.

https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops says:
"If you need to perform a side effect (for example, data fetching or an animation) in response to a change in props, use componentDidUpdate lifecycle instead."

componentDidUpdate is called after updating, rather than componentWillRecieveProps.
If this (or some other subtle change) happens to break atom, then I'll just use UNSAFE_componentWillReceiveProps instead.

Warning text:


Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

In this case, it's used for side effects (1st bullet point)

And this implies there will still be a warning when using UNSAFE_componentWillReceiveProps in strict-mode, so trying componentDidUpdate first.

Screenshot or Gif

N/A

Applicable Issues

(削除) Fixes (削除ここまで) (削除) Part of (削除ここまで) Fixes #2680

Copy link
Author

The tests failed, but for external reasons
image

Also there's this:
image

Copy link
Contributor

@smashwilson smashwilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work 👍🏻

It looks like we have another use of componentWillReceiveProps in the codebase, though. Can we leave the linked issue open until that's converted, as well?

Copy link
Contributor

The tests failed, but for external reasons

Yeah, our CI seems really unhealthy 😒 . It was always a bit rickety even when this was my major focus, but it looks like entropy has made it even worse since the last time I've done work here.

`_prevProps` is unused, that's why it has an underscore. Maybe atom does something differently?
Copy link

codecov bot commented Sep 2, 2021
edited
Loading

Codecov Report

Merging #2681 (8b1cfaf) into master (2053290) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@
## master #2681 +/- ##
=======================================
 Coverage 93.46% 93.46% 
=======================================
 Files 237 237 
 Lines 13213 13213 
 Branches 1900 1900 
=======================================
 Hits 12349 12349 
 Misses 864 864 
Impacted Files Coverage Δ
lib/atom/commands.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2053290...8b1cfaf. Read the comment docs.

Copy link
Author

That last commit was for the tests to run

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

Reviewers

2 more reviewers

@smashwilson smashwilson smashwilson approved these changes

@unrealapex unrealapex unrealapex approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Warning: componentWillReceiveProps has been renamed, and is not recommended for use.

AltStyle によって変換されたページ (->オリジナル) /