Skip to content

unify deprecated/unsafe lifecycle warnings, pass tests - #16103

Merged
threepointone merged 1 commit into
react:masterfrom
threepointone:lifecycle-warnings
Jul 15, 2019
Merged

unify deprecated/unsafe lifecycle warnings, pass tests#16103
threepointone merged 1 commit into
react:masterfrom
threepointone:lifecycle-warnings

Conversation

@threepointone

@threepointonethreepointone commented Jul 10, 2019

Copy link
Copy Markdown
Contributor

This PR tweaks the deprecated/unsafe lifecycle warnings.

  • redoes tweak unsafe lifecycle warnings #15431 from scratch, taking on the feedback there
  • unifies the messaging between "deprecated" and UNSAFE_ lifecycle messages. It reorganises ReactStrictModeWarnings.js to capture and flush all the lifecycle warnings in one procedure each.
  • this DOES NOT do the above treatment for context warnings, I'll do that in another PR too
  • matches the warning from ReactPartialRenderer to match the above treatment
  • passes all the tests
  • this also turns on warnAboutDeprecatedLifecycles for the test renderer. I think we missed doing so it previously. In a future PR, I'll remove the feature flag altogether.

Things to do in future PRs asap -

Screenshot:
image

@sizebot

sizebot commented Jul 10, 2019

Copy link
Copy Markdown
Details of bundled changes.

Comparing: 9f39590...9505272

react-art

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
react-art.development.js+0.2%0.0%629.08 KB630.25 KB138 KB138.03 KBUMD_DEV
react-art.production.min.js0.0%0.0%102.26 KB102.26 KB31.3 KB31.3 KBUMD_PROD
react-art.development.js+0.2%0.0%559.94 KB561.11 KB120.63 KB120.65 KBNODE_DEV
react-art.production.min.js0.0%0.0%67.31 KB67.31 KB20.62 KB20.62 KBNODE_PROD
ReactART-dev.js+0.2%-0.0%572.96 KB574.37 KB120.21 KB120.18 KBFB_WWW_DEV
ReactART-prod.js0.0%-0.0%218.46 KB218.46 KB37.08 KB37.08 KBFB_WWW_PROD

react-dom

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
react-dom.profiling.min.js0.0%0.0%115.01 KB115.01 KB36.26 KB36.26 KBNODE_PROFILING
react-dom-server.browser.development.js+0.1%+0.1%135.74 KB135.84 KB35.81 KB35.86 KBUMD_DEV
ReactDOM-dev.js+0.2%-0.0%915.52 KB916.93 KB203.49 KB203.46 KBFB_WWW_DEV
react-dom-test-utils.development.js0.0%0.0%57.96 KB57.96 KB15.91 KB15.91 KBUMD_DEV
react-dom-unstable-fizz.browser.development.js0.0%+0.1%3.78 KB3.78 KB1.52 KB1.52 KBUMD_DEV
react-dom-test-utils.production.min.js0.0%0.0%10.95 KB10.95 KB4.01 KB4.01 KBUMD_PROD
react-dom-unstable-fizz.browser.production.min.js0.0%🔺+0.3%1.21 KB1.21 KB706 B708 BUMD_PROD
react-dom-unstable-fizz.browser.development.js0.0%+0.1%3.61 KB3.61 KB1.48 KB1.48 KBNODE_DEV
react-dom-test-utils.production.min.js0.0%-0.0%10.71 KB10.71 KB3.95 KB3.95 KBNODE_PROD
react-dom-unstable-fizz.browser.production.min.js0.0%🔺+0.3%1.05 KB1.05 KB637 B639 BNODE_PROD
react-dom.development.js+0.1%0.0%892.87 KB894.04 KB203.11 KB203.13 KBUMD_DEV
react-dom.profiling.min.js0.0%0.0%114.73 KB114.73 KB36.87 KB36.87 KBUMD_PROFILING
react-dom.development.js+0.1%0.0%887.16 KB888.33 KB201.6 KB201.62 KBNODE_DEV
react-dom-server.node.development.js+0.1%+0.1%133.8 KB133.9 KB35.43 KB35.47 KBNODE_DEV
react-dom.production.min.js0.0%0.0%111.36 KB111.36 KB35.32 KB35.32 KBNODE_PROD
ReactDOM-profiling.js0.0%0.0%377.65 KB377.65 KB69.39 KB69.39 KBFB_WWW_PROFILING
react-dom-server.browser.development.js+0.1%+0.1%131.88 KB131.97 KB34.89 KB34.93 KBNODE_DEV
react-dom-unstable-native-dependencies.development.js0.0%0.0%60.76 KB60.76 KB15.85 KB15.85 KBUMD_DEV
react-dom-unstable-native-dependencies.production.min.js0.0%0.0%10.74 KB10.74 KB3.68 KB3.68 KBUMD_PROD
ReactDOMServer-dev.js0.0%+0.1%134.27 KB134.32 KB34.45 KB34.49 KBFB_WWW_DEV
ReactDOMServer-prod.js0.0%-0.0%46.67 KB46.67 KB10.74 KB10.74 KBFB_WWW_PROD
react-dom-unstable-native-dependencies.development.js0.0%0.0%60.43 KB60.43 KB15.72 KB15.72 KBNODE_DEV
react-dom-unstable-fizz.node.production.min.js0.0%🔺+0.1%1.1 KB1.1 KB668 B669 BNODE_PROD

react-test-renderer

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
ReactTestRenderer-dev.js+0.2%-0.0%582.88 KB584.29 KB122.54 KB122.52 KBFB_WWW_DEV
react-test-renderer-shallow.development.js0.0%0.0%35.6 KB35.6 KB9.41 KB9.42 KBNODE_DEV
react-test-renderer-shallow.production.min.js0.0%0.0%11.8 KB11.8 KB3.68 KB3.68 KBNODE_PROD
react-test-renderer.development.js+0.2%0.0%572.29 KB573.46 KB123.31 KB123.33 KBUMD_DEV
react-test-renderer.production.min.js0.0%0.0%68.67 KB68.67 KB21.07 KB21.07 KBUMD_PROD
react-test-renderer.development.js+0.2%0.0%567.83 KB569 KB122.17 KB122.2 KBNODE_DEV
react-test-renderer.production.min.js0.0%0.0%68.38 KB68.38 KB20.82 KB20.82 KBNODE_PROD

react-reconciler

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
react-reconciler.development.js+0.2%0.0%558.14 KB559.32 KB119.16 KB119.18 KBNODE_DEV
react-reconciler-reflection.development.js0.0%0.0%18.66 KB18.66 KB6.03 KB6.03 KBNODE_DEV
react-reconciler-reflection.production.min.js0.0%🔺+0.1%2.58 KB2.58 KB1.13 KB1.13 KBNODE_PROD
react-reconciler-persistent.development.js+0.2%0.0%555.73 KB556.9 KB118.1 KB118.12 KBNODE_DEV
react-reconciler-persistent.production.min.js0.0%0.0%68.57 KB68.57 KB20.41 KB20.41 KBNODE_PROD

react-native-renderer

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
ReactNativeRenderer-profiling.js0.0%0.0%280.67 KB280.67 KB48.36 KB48.36 KBRN_OSS_PROFILING
ReactFabric-dev.js+0.2%-0.0%721.52 KB722.93 KB153.49 KB153.45 KBRN_FB_DEV
ReactNativeRenderer-dev.js+0.2%-0.0%707.96 KB709.36 KB150.87 KB150.84 KBRN_OSS_DEV
ReactNativeRenderer-dev.js+0.2%-0.0%708.05 KB709.46 KB150.92 KB150.89 KBRN_FB_DEV
ReactFabric-dev.js+0.2%-0.0%721.42 KB722.83 KB153.44 KB153.41 KBRN_OSS_DEV

Generated by 🚫 dangerJS

@bvaughnbvaughn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These lifecycles are actually deprecated and will be removed in the next major version. I think changing the message to "not recommended" is a mistake.

Edit for clarity I think it's okay to say

Using UNSAFE_componentWillMount in strict mode is not recommended

But I don't think it's good to say:

Using componentWillMount in strict mode is not recommended

I think our warning needs to be more than just "not recommended" because the idea is that it will stop working in a future version.

@threepointone

Copy link
Copy Markdown
ContributorAuthor

Good point, happy to change it

@threepointone

Copy link
Copy Markdown
ContributorAuthor

How do you feel about “...has been renamed to...”? I’m only trying to avoid the word ‘deprecated’.

@bvaughn

Copy link
Copy Markdown
Contributor

I am okay with "has been renamed to" in addition to advising against its usage.

@threepointone

Copy link
Copy Markdown
ContributorAuthor

I updated the diff only to pass the build error, will continue tweaking the wording. Still not 100% sure yet tbh.

@threepointone
threepointoneforce-pushed the lifecycle-warnings branch 4 times, most recently from ec7b480 to e7127aaCompareJuly 11, 2019 12:27
@threepointone
threepointoneforce-pushed the lifecycle-warnings branch 2 times, most recently from 1c57951 to d41920bCompareJuly 11, 2019 15:53
Comment threadpackages/react-reconciler/src/__tests__/ReactIncremental-test.internal.js Outdated
Comment threadpackages/react-reconciler/src/ReactStrictModeWarnings.js Outdated
Comment threadpackages/react-reconciler/src/ReactStrictModeWarnings.js Outdated
Comment threadpackages/react-reconciler/src/ReactStrictModeWarnings.js Outdated
Comment threadpackages/react-reconciler/src/ReactStrictModeWarnings.js Outdated
@threepointone
threepointoneforce-pushed the lifecycle-warnings branch 4 times, most recently from abe5f20 to e296fc4CompareJuly 12, 2019 11:46

@trueadmtrueadm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The usage of the phrase "(preferred in most cases)" seems unnecessary and confusing to me. What cases? Why are they preferred in some cases but not others?

I think it's important we get this right, otherwise we're just going to cause pain for quite a large segment of users who are upgrading from an older version.

Comment threadpackages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js Outdated
Comment threadpackages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js Outdated
@threepointone

Copy link
Copy Markdown
ContributorAuthor

updated messages, screenshot.

This was referenced Mar 10, 2020
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
- redoes react#15431 from scratch, taking on the feedback there
- unifies the messaging between "deprecated" and UNSAFE_ lifecycle messages. It reorganizes ReactStrictModeWarnings.js to capture and flush all the lifecycle warnings in one procedure each.
- matches the warning from ReactPartialRenderer to match the above change
- passes all the tests
- this also turns on `warnAboutDeprecatedLifecycles` for the test renderer. I think we missed doing so it previously. In a future PR, I'll remove the feature flag altogether.
- this DOES NOT do the same treatment for context warnings, I'll do that in another PR too
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@threepointone@sizebot@bvaughn@gaearon@trueadm@facebook-github-bot