From c35e37aabd01c15b006334da7e32171948ea941e Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Wed, 3 Apr 2019 17:11:24 +0100 Subject: [PATCH 1/6] mark react-events as private so we publish script skips it for now --- packages/react-events/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-events/package.json b/packages/react-events/package.json index 0950a38579bc..e293b88fed26 100644 --- a/packages/react-events/package.json +++ b/packages/react-events/package.json @@ -1,5 +1,6 @@ { "name": "react-events", + "private": true, "description": "React is a JavaScript library for building user interfaces.", "keywords": [ "react" From e3b06c6169c7f43b5a3bd2cec1fa27206855c5cf Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Wed, 17 Apr 2019 13:08:43 +0100 Subject: [PATCH 2/6] tweak unsafe lifecycle warnings to include codemod suggestion --- .../__tests__/ReactComponentLifeCycle-test.js | 29 ++++++---- .../src/ReactStrictModeWarnings.js | 55 +++++++++++++------ ...eateReactClassIntegration-test.internal.js | 19 ++++--- 3 files changed, 68 insertions(+), 35 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js index fd286f1e68c8..ba951d87c1b8 100644 --- a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js +++ b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js @@ -1403,17 +1403,24 @@ describe('ReactComponentLifeCycle', () => { ReactDOM.render(, container), ).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated and will be removed in the next major version. ' + - 'Use componentDidMount instead. As a temporary workaround, ' + - 'you can rename to UNSAFE_componentWillMount.' + - '\n\nPlease update the following components: MyComponent', - 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + - 'Use static getDerivedStateFromProps instead.' + - '\n\nPlease update the following components: MyComponent', - 'componentWillUpdate is deprecated and will be removed in the next major version. ' + - 'Use componentDidUpdate instead. As a temporary workaround, ' + - 'you can rename to UNSAFE_componentWillUpdate.' + - '\n\nPlease update the following components: MyComponent', + 'componentWillMount is deprecated and will be removed in the next major version.\n' + + 'Consider one of the following options to silence this warning:\n' + + '- Use componentDidMount instead.\n' + + '- To silence the warning in non-strict mode, rename componentWillMount to UNSAFE_componentWillMount.\n' + + '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + '\nPlease update the following components: MyComponent\n', + 'componentWillReceiveProps is deprecated and will be removed in the next major version.\n' + + 'Consider one of the following options to silence this warning:\n' + + '- Use static getDerivedStateFromProps instead.\n' + + '- To silence the warning in non-strict mode, rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps.\n' + + '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + '\nPlease update the following components: MyComponent\n', + 'componentWillUpdate is deprecated and will be removed in the next major version.\n' + + 'Consider one of the following options to silence this warning:\n' + + '- Use componentDidUpdate instead.\n' + + '- To silence the warning in non-strict mode, rename componentWillUpdate to UNSAFE_componentWillUpdate.\n' + + '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + '\nPlease update the following components: MyComponent\n', ], {withoutStack: true}, ); diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.js b/packages/react-reconciler/src/ReactStrictModeWarnings.js index 143e7ebd4a7b..df98dd8a1165 100644 --- a/packages/react-reconciler/src/ReactStrictModeWarnings.js +++ b/packages/react-reconciler/src/ReactStrictModeWarnings.js @@ -141,12 +141,14 @@ if (__DEV__) { lowPriorityWarning( false, - 'componentWillMount is deprecated and will be removed in the next major version. ' + - 'Use componentDidMount instead. As a temporary workaround, ' + - 'you can rename to UNSAFE_componentWillMount.' + - '\n\nPlease update the following components: %s' + - '\n\nLearn more about this warning here:' + - '\nhttps://fb.me/react-async-component-lifecycle-hooks', + 'componentWillMount is deprecated and will be removed in the next major version.\n' + + 'Consider one of the following options to silence this warning:\n' + + '- Use componentDidMount instead.\n' + + '- To silence the warning in non-strict mode, rename componentWillMount to UNSAFE_componentWillMount.\n' + + '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + '\nPlease update the following components: %s\n' + + '\nLearn more about this warning here:\n' + + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); @@ -164,11 +166,14 @@ if (__DEV__) { lowPriorityWarning( false, - 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + - 'Use static getDerivedStateFromProps instead.' + - '\n\nPlease update the following components: %s' + - '\n\nLearn more about this warning here:' + - '\nhttps://fb.me/react-async-component-lifecycle-hooks', + 'componentWillReceiveProps is deprecated and will be removed in the next major version.\n' + + 'Consider one of the following options to silence this warning:\n' + + '- Use static getDerivedStateFromProps instead.\n' + + '- To silence the warning in non-strict mode, rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps.\n' + + '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + '\nPlease update the following components: %s\n' + + '\nLearn more about this warning here:\n' + + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); @@ -186,12 +191,14 @@ if (__DEV__) { lowPriorityWarning( false, - 'componentWillUpdate is deprecated and will be removed in the next major version. ' + - 'Use componentDidUpdate instead. As a temporary workaround, ' + - 'you can rename to UNSAFE_componentWillUpdate.' + - '\n\nPlease update the following components: %s' + - '\n\nLearn more about this warning here:' + - '\nhttps://fb.me/react-async-component-lifecycle-hooks', + 'componentWillUpdate is deprecated and will be removed in the next major version.\n' + + 'Consider one of the following options to silence this warning:\n' + + '- Use componentDidUpdate instead.\n' + + '- To silence the warning in non-strict mode, rename componentWillUpdate to UNSAFE_componentWillUpdate.\n' + + '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + '\nPlease update the following components: %s\n' + + '\nLearn more about this warning here:\n' + + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); @@ -361,3 +368,17 @@ if (__DEV__) { } export default ReactStrictModeWarnings; + +/* + +componentWillMount is deprecated and will be removed in the next major version. +Consider one of the following options to silence this warning: +- Use componentDidMount instead. +- To silence the warning in non-strict mode, you can rename this to UNSAFE_componentWillMount. +- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line. + +Please update the following components: %s + +Learn more about this warning here: +https://fb.me/react-async-component-lifecycle-hooks +*/ diff --git a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js index b1bd7c9b1c91..49256fa2783b 100644 --- a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js +++ b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js @@ -51,10 +51,12 @@ describe('create-react-class-integration', () => { }); expect(() => ReactNative.render(, 1)).toLowPriorityWarnDev( - 'componentWillMount is deprecated and will be removed in the next major version. ' + - 'Use componentDidMount instead. As a temporary workaround, ' + - 'you can rename to UNSAFE_componentWillMount.' + - '\n\nPlease update the following components: MyNativeComponent', + 'componentWillMount is deprecated and will be removed in the next major version.\n' + + 'Consider one of the following options to silence this warning:\n' + + '- Use componentDidMount instead.\n' + + '- To silence the warning in non-strict mode, rename componentWillMount to UNSAFE_componentWillMount.\n' + + '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + '\nPlease update the following components: MyNativeComponent\n', {withoutStack: true}, ); }); @@ -68,9 +70,12 @@ describe('create-react-class-integration', () => { }); expect(() => ReactNative.render(, 1)).toLowPriorityWarnDev( - 'componentWillReceiveProps is deprecated and will be removed in the next major version. ' + - 'Use static getDerivedStateFromProps instead.' + - '\n\nPlease update the following components: MyNativeComponent', + 'componentWillReceiveProps is deprecated and will be removed in the next major version.\n' + + 'Consider one of the following options to silence this warning:\n' + + '- Use static getDerivedStateFromProps instead.\n' + + '- To silence the warning in non-strict mode, rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps.\n' + + '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + '\nPlease update the following components: MyNativeComponent\n', {withoutStack: true}, ); }); From d884ec3e5de13d3ce4b69dda37c1e8b5b24bd03f Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Wed, 17 Apr 2019 13:13:50 +0100 Subject: [PATCH 3/6] stray comment --- .../src/ReactStrictModeWarnings.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.js b/packages/react-reconciler/src/ReactStrictModeWarnings.js index df98dd8a1165..21ea81ae366c 100644 --- a/packages/react-reconciler/src/ReactStrictModeWarnings.js +++ b/packages/react-reconciler/src/ReactStrictModeWarnings.js @@ -368,17 +368,3 @@ if (__DEV__) { } export default ReactStrictModeWarnings; - -/* - -componentWillMount is deprecated and will be removed in the next major version. -Consider one of the following options to silence this warning: -- Use componentDidMount instead. -- To silence the warning in non-strict mode, you can rename this to UNSAFE_componentWillMount. -- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line. - -Please update the following components: %s - -Learn more about this warning here: -https://fb.me/react-async-component-lifecycle-hooks -*/ From ea444d2b4a3e9935452b40d1d039cad5ee5da657 Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Thu, 18 Apr 2019 13:31:48 +0100 Subject: [PATCH 4/6] more tweaks, update more tests --- .../__tests__/ReactComponentLifeCycle-test.js | 80 ++++++++++++------- .../ReactDOMServerLifecycles-test.js | 17 ++-- .../ReactServerRenderingHydration-test.js | 4 +- .../src/server/ReactPartialRenderer.js | 18 +++-- .../src/ReactStrictModeWarnings.js | 50 +++++++----- .../ReactStrictMode-test.internal.js | 8 +- ...eateReactClassIntegration-test.internal.js | 30 ++++--- .../createReactClassIntegration-test.js | 18 ++--- 8 files changed, 135 insertions(+), 90 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js index ba951d87c1b8..91529f6017d6 100644 --- a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js +++ b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js @@ -709,9 +709,9 @@ describe('ReactComponentLifeCycle', () => { ); }).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated', - 'componentWillReceiveProps is deprecated', - 'componentWillUpdate is deprecated', + 'componentWillMount has been renamed', + 'componentWillReceiveProps has been renamed', + 'componentWillUpdate has been renamed', ], {withoutStack: true}, ); @@ -748,9 +748,9 @@ describe('ReactComponentLifeCycle', () => { ); }).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated', - 'componentWillReceiveProps is deprecated', - 'componentWillUpdate is deprecated', + 'componentWillMount has been renamed', + 'componentWillReceiveProps has been renamed', + 'componentWillUpdate has been renamed', ], {withoutStack: true}, ); @@ -815,7 +815,10 @@ describe('ReactComponentLifeCycle', () => { {withoutStack: true}, ); }).toLowPriorityWarnDev( - ['componentWillMount is deprecated', 'componentWillUpdate is deprecated'], + [ + 'componentWillMount has been renamed', + 'componentWillUpdate has been renamed', + ], {withoutStack: true}, ); @@ -863,7 +866,7 @@ describe('ReactComponentLifeCycle', () => { 'https://fb.me/react-async-component-lifecycle-hooks', {withoutStack: true}, ); - }).toLowPriorityWarnDev(['componentWillMount is deprecated'], { + }).toLowPriorityWarnDev(['componentWillMount has been renamed'], { withoutStack: true, }); @@ -887,7 +890,7 @@ describe('ReactComponentLifeCycle', () => { 'https://fb.me/react-async-component-lifecycle-hooks', {withoutStack: true}, ); - }).toLowPriorityWarnDev(['componentWillReceiveProps is deprecated'], { + }).toLowPriorityWarnDev(['componentWillReceiveProps has been renamed'], { withoutStack: true, }); }); @@ -921,7 +924,10 @@ describe('ReactComponentLifeCycle', () => { {withoutStack: true}, ); }).toLowPriorityWarnDev( - ['componentWillMount is deprecated', 'componentWillUpdate is deprecated'], + [ + 'componentWillMount has been renamed', + 'componentWillUpdate has been renamed', + ], {withoutStack: true}, ); @@ -967,7 +973,7 @@ describe('ReactComponentLifeCycle', () => { 'https://fb.me/react-async-component-lifecycle-hooks', {withoutStack: true}, ); - }).toLowPriorityWarnDev(['componentWillMount is deprecated'], { + }).toLowPriorityWarnDev(['componentWillMount has been renamed'], { withoutStack: true, }); @@ -990,7 +996,7 @@ describe('ReactComponentLifeCycle', () => { 'https://fb.me/react-async-component-lifecycle-hooks', {withoutStack: true}, ); - }).toLowPriorityWarnDev(['componentWillReceiveProps is deprecated'], { + }).toLowPriorityWarnDev(['componentWillReceiveProps has been renamed'], { withoutStack: true, }); }); @@ -1130,9 +1136,9 @@ describe('ReactComponentLifeCycle', () => { ReactDOM.render(, div), ).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated', - 'componentWillReceiveProps is deprecated', - 'componentWillUpdate is deprecated', + 'componentWillMount has been renamed', + 'componentWillReceiveProps has been renamed', + 'componentWillUpdate has been renamed', ], {withoutStack: true}, ); @@ -1403,23 +1409,37 @@ describe('ReactComponentLifeCycle', () => { ReactDOM.render(, container), ).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated and will be removed in the next major version.\n' + - 'Consider one of the following options to silence this warning:\n' + - '- Use componentDidMount instead.\n' + - '- To silence the warning in non-strict mode, rename componentWillMount to UNSAFE_componentWillMount.\n' + - '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + + '- If you fetch data or perform other side effects in componentWillMount, ' + + 'move this logic into componentDidMount.\n' + '\nPlease update the following components: MyComponent\n', - 'componentWillReceiveProps is deprecated and will be removed in the next major version.\n' + - 'Consider one of the following options to silence this warning:\n' + - '- Use static getDerivedStateFromProps instead.\n' + - '- To silence the warning in non-strict mode, rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps.\n' + - '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + "- If you're updating state whenever props change, " + + 'move this logic into static getDerivedStateFromProps.\n' + + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + + 'move this logic into componentDidUpdate.\n' + + '- Refactor your code to not use derived state at all, as described at ' + + // todo - this should be an fb.me link + 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + '\nPlease update the following components: MyComponent\n', - 'componentWillUpdate is deprecated and will be removed in the next major version.\n' + - 'Consider one of the following options to silence this warning:\n' + - '- Use componentDidUpdate instead.\n' + - '- To silence the warning in non-strict mode, rename componentWillUpdate to UNSAFE_componentWillUpdate.\n' + - '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + 'componentWillUpdate has been renamed to UNSAFE_componentWillUpdate, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + '- If you fetch data or perform other side effects in componentWillUpdate, ' + + 'move this logic into componentDidUpdate.\n' + + "- If you're reading DOM properties before an update, " + + 'move this logic into getSnapshotBeforeUpdate.\n' + '\nPlease update the following components: MyComponent\n', ], {withoutStack: true}, diff --git a/packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js b/packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js index 76230a323035..4aed0e0246a6 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerLifecycles-test.js @@ -229,7 +229,7 @@ describe('ReactDOMServerLifecycles', () => { expect(() => ReactDOMServer.renderToString(), - ).toLowPriorityWarnDev('componentWillMount() is deprecated', { + ).toLowPriorityWarnDev('componentWillMount has been renamed', { withoutStack: true, }); expect(log).toEqual(['componentWillMount', 'UNSAFE_componentWillMount']); @@ -286,10 +286,9 @@ describe('ReactDOMServerLifecycles', () => { expect(() => ReactDOMServer.renderToString(), - ).toLowPriorityWarnDev( - 'Component: componentWillMount() is deprecated and will be removed in the next major version.', - {withoutStack: true}, - ); + ).toLowPriorityWarnDev('componentWillMount has been renamed', { + withoutStack: true, + }); }); it('should warn about deprecated lifecycle hooks', () => { @@ -302,11 +301,9 @@ describe('ReactDOMServerLifecycles', () => { expect(() => ReactDOMServer.renderToString(), - ).toLowPriorityWarnDev( - 'Warning: Component: componentWillMount() is deprecated and will be removed ' + - 'in the next major version.', - {withoutStack: true}, - ); + ).toLowPriorityWarnDev('componentWillMount has been renamed', { + withoutStack: true, + }); // De-duped ReactDOMServer.renderToString(); diff --git a/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js b/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js index 4d046af383ce..f107446c5a86 100644 --- a/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js @@ -363,7 +363,7 @@ describe('ReactDOMServerHydration', () => { expect(() => { element.innerHTML = ReactDOMServer.renderToString(markup); }).toLowPriorityWarnDev( - ['componentWillMount() is deprecated and will be removed'], + ['componentWillMount has been renamed to UNSAFE_componentWillMount'], {withoutStack: true}, ); expect(element.textContent).toBe('Hi'); @@ -373,7 +373,7 @@ describe('ReactDOMServerHydration', () => { 'Please update the following components to use componentDidMount instead: ComponentWithWarning', ); }).toLowPriorityWarnDev( - ['componentWillMount is deprecated and will be removed'], + ['componentWillMount has been renamed to UNSAFE_componentWillMount'], {withoutStack: true}, ); expect(element.textContent).toBe('Hi'); diff --git a/packages/react-dom/src/server/ReactPartialRenderer.js b/packages/react-dom/src/server/ReactPartialRenderer.js index ce078dcb7177..fff42b69767a 100644 --- a/packages/react-dom/src/server/ReactPartialRenderer.js +++ b/packages/react-dom/src/server/ReactPartialRenderer.js @@ -573,13 +573,17 @@ function resolve( if (!didWarnAboutDeprecatedWillMount[componentName]) { lowPriorityWarning( false, - '%s: componentWillMount() is deprecated and will be ' + - 'removed in the next major version. Read about the motivations ' + - 'behind this change: ' + - 'https://fb.me/react-async-component-lifecycle-hooks' + - '\n\n' + - 'As a temporary workaround, you can rename to ' + - 'UNSAFE_componentWillMount instead.', + 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + + '- If you fetch data or perform other side effects in componentWillMount, ' + + 'move this logic into componentDidMount.\n' + + '\nPlease update the following components: %s\n' + + '\nLearn about this warning, with more examples and suggestions here:\n' + + 'https://fb.me/react-async-component-lifecycle-hooks', componentName, ); didWarnAboutDeprecatedWillMount[componentName] = true; diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.js b/packages/react-reconciler/src/ReactStrictModeWarnings.js index 21ea81ae366c..5f8970f4b8f9 100644 --- a/packages/react-reconciler/src/ReactStrictModeWarnings.js +++ b/packages/react-reconciler/src/ReactStrictModeWarnings.js @@ -141,13 +141,16 @@ if (__DEV__) { lowPriorityWarning( false, - 'componentWillMount is deprecated and will be removed in the next major version.\n' + - 'Consider one of the following options to silence this warning:\n' + - '- Use componentDidMount instead.\n' + - '- To silence the warning in non-strict mode, rename componentWillMount to UNSAFE_componentWillMount.\n' + - '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + + '- If you fetch data or perform other side effects in componentWillMount, ' + + 'move this logic into componentDidMount.\n' + '\nPlease update the following components: %s\n' + - '\nLearn more about this warning here:\n' + + '\nLearn about this warning, with more examples and suggestions here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); @@ -166,13 +169,20 @@ if (__DEV__) { lowPriorityWarning( false, - 'componentWillReceiveProps is deprecated and will be removed in the next major version.\n' + - 'Consider one of the following options to silence this warning:\n' + - '- Use static getDerivedStateFromProps instead.\n' + - '- To silence the warning in non-strict mode, rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps.\n' + - '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + "- If you're updating state whenever props change, " + + 'move this logic into static getDerivedStateFromProps.\n' + + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + + 'move this logic into componentDidUpdate.\n' + + '- Refactor your code to not use derived state at all, as described at ' + + // todo - this should be an fb.me link + 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + '\nPlease update the following components: %s\n' + - '\nLearn more about this warning here:\n' + + '\nLearn about this warning, with more examples and suggestions here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); @@ -191,13 +201,17 @@ if (__DEV__) { lowPriorityWarning( false, - 'componentWillUpdate is deprecated and will be removed in the next major version.\n' + - 'Consider one of the following options to silence this warning:\n' + - '- Use componentDidUpdate instead.\n' + - '- To silence the warning in non-strict mode, rename componentWillUpdate to UNSAFE_componentWillUpdate.\n' + - '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + 'componentWillUpdate has been renamed to UNSAFE_componentWillUpdate, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + '- If you fetch data or perform other side effects in componentWillUpdate, ' + + 'move this logic into componentDidUpdate.\n' + + "- If you're reading DOM properties before an update, " + + 'move this logic into getSnapshotBeforeUpdate.\n' + '\nPlease update the following components: %s\n' + - '\nLearn more about this warning here:\n' + + '\nLearn about this warning, with more examples and suggestions here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); diff --git a/packages/react/src/__tests__/ReactStrictMode-test.internal.js b/packages/react/src/__tests__/ReactStrictMode-test.internal.js index 14b33ce99180..d7939d1327ec 100644 --- a/packages/react/src/__tests__/ReactStrictMode-test.internal.js +++ b/packages/react/src/__tests__/ReactStrictMode-test.internal.js @@ -429,9 +429,9 @@ describe('ReactStrictMode', () => { ); }).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated', - 'componentWillReceiveProps is deprecated', - 'componentWillUpdate is deprecated', + 'componentWillMount has been renamed', + 'componentWillReceiveProps has been renamed', + 'componentWillUpdate has been renamed', ], {withoutStack: true}, ); @@ -517,7 +517,7 @@ describe('ReactStrictMode', () => { '\n\ncomponentWillMount: Please update the following components ' + 'to use componentDidMount instead: Baz', ]); - }).toLowPriorityWarnDev(['componentWillMount is deprecated'], { + }).toLowPriorityWarnDev(['componentWillMount has been renamed'], { withoutStack: true, }); diff --git a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js index 49256fa2783b..e5b37593174a 100644 --- a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js +++ b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js @@ -51,11 +51,14 @@ describe('create-react-class-integration', () => { }); expect(() => ReactNative.render(, 1)).toLowPriorityWarnDev( - 'componentWillMount is deprecated and will be removed in the next major version.\n' + - 'Consider one of the following options to silence this warning:\n' + - '- Use componentDidMount instead.\n' + - '- To silence the warning in non-strict mode, rename componentWillMount to UNSAFE_componentWillMount.\n' + - '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + + '- If you fetch data or perform other side effects in componentWillMount, ' + + 'move this logic into componentDidMount.\n' + '\nPlease update the following components: MyNativeComponent\n', {withoutStack: true}, ); @@ -70,11 +73,18 @@ describe('create-react-class-integration', () => { }); expect(() => ReactNative.render(, 1)).toLowPriorityWarnDev( - 'componentWillReceiveProps is deprecated and will be removed in the next major version.\n' + - 'Consider one of the following options to silence this warning:\n' + - '- Use static getDerivedStateFromProps instead.\n' + - '- To silence the warning in non-strict mode, rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps.\n' + - '- To automatically rename all unsafe lifecycle methods in your codebase, run `npx react-codemod rename-unsafe-lifecycles ` in your command line.\n' + + 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + + "and the old name won't work in the next major version of React.\n" + + 'We suggest doing one of the following:\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + + "- If you're updating state whenever props change, " + + 'move this logic into static getDerivedStateFromProps.\n' + + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + + 'move this logic into componentDidUpdate.\n' + + '- Refactor your code to not use derived state at all, as described at ' + + // todo - this should be an fb.me link + 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + '\nPlease update the following components: MyNativeComponent\n', {withoutStack: true}, ); diff --git a/packages/react/src/__tests__/createReactClassIntegration-test.js b/packages/react/src/__tests__/createReactClassIntegration-test.js index 36b6bb047732..542a35087033 100644 --- a/packages/react/src/__tests__/createReactClassIntegration-test.js +++ b/packages/react/src/__tests__/createReactClassIntegration-test.js @@ -560,9 +560,9 @@ describe('create-react-class-integration', () => { ); }).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated', - 'componentWillReceiveProps is deprecated', - 'componentWillUpdate is deprecated', + 'componentWillMount has been renamed', + 'componentWillReceiveProps has been renamed', + 'componentWillUpdate has been renamed', ], {withoutStack: true}, ); @@ -604,9 +604,9 @@ describe('create-react-class-integration', () => { ); }).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated', - 'componentWillReceiveProps is deprecated', - 'componentWillUpdate is deprecated', + 'componentWillMount has been renamed', + 'componentWillReceiveProps has been renamed', + 'componentWillUpdate has been renamed', ], {withoutStack: true}, ); @@ -649,9 +649,9 @@ describe('create-react-class-integration', () => { ReactDOM.render(, div), ).toLowPriorityWarnDev( [ - 'componentWillMount is deprecated', - 'componentWillReceiveProps is deprecated', - 'componentWillUpdate is deprecated', + 'componentWillMount has been renamed', + 'componentWillReceiveProps has been renamed', + 'componentWillUpdate has been renamed', ], {withoutStack: true}, ); From 05239098726843b9a6ba0b36cf5a1ca21c5d4f5a Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Thu, 18 Apr 2019 17:42:21 +0100 Subject: [PATCH 5/6] move the codemod line to the end, add "Note that the warning will still be logged in strict mode". --- .../__tests__/ReactComponentLifeCycle-test.js | 17 +++++++++++------ .../src/ReactStrictModeWarnings.js | 15 +++++++++------ ...createReactClassIntegration-test.internal.js | 10 ++++++---- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js index 91529f6017d6..7976766ee831 100644 --- a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js +++ b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js @@ -1412,17 +1412,17 @@ describe('ReactComponentLifeCycle', () => { 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + '- If you fetch data or perform other side effects in componentWillMount, ' + 'move this logic into componentDidMount.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: MyComponent\n', + 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + "- If you're updating state whenever props change, " + 'move this logic into static getDerivedStateFromProps.\n' + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + @@ -1430,16 +1430,21 @@ describe('ReactComponentLifeCycle', () => { '- Refactor your code to not use derived state at all, as described at ' + // todo - this should be an fb.me link 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: MyComponent\n', + 'componentWillUpdate has been renamed to UNSAFE_componentWillUpdate, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + '- If you fetch data or perform other side effects in componentWillUpdate, ' + 'move this logic into componentDidUpdate.\n' + "- If you're reading DOM properties before an update, " + 'move this logic into getSnapshotBeforeUpdate.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: MyComponent\n', ], {withoutStack: true}, diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.js b/packages/react-reconciler/src/ReactStrictModeWarnings.js index 5f8970f4b8f9..39cfcb41513a 100644 --- a/packages/react-reconciler/src/ReactStrictModeWarnings.js +++ b/packages/react-reconciler/src/ReactStrictModeWarnings.js @@ -144,11 +144,12 @@ if (__DEV__) { 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + '- If you fetch data or perform other side effects in componentWillMount, ' + 'move this logic into componentDidMount.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: %s\n' + '\nLearn about this warning, with more examples and suggestions here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', @@ -172,8 +173,6 @@ if (__DEV__) { 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + "- If you're updating state whenever props change, " + 'move this logic into static getDerivedStateFromProps.\n' + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + @@ -181,6 +180,9 @@ if (__DEV__) { '- Refactor your code to not use derived state at all, as described at ' + // todo - this should be an fb.me link 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: %s\n' + '\nLearn about this warning, with more examples and suggestions here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', @@ -204,12 +206,13 @@ if (__DEV__) { 'componentWillUpdate has been renamed to UNSAFE_componentWillUpdate, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + '- If you fetch data or perform other side effects in componentWillUpdate, ' + 'move this logic into componentDidUpdate.\n' + "- If you're reading DOM properties before an update, " + 'move this logic into getSnapshotBeforeUpdate.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: %s\n' + '\nLearn about this warning, with more examples and suggestions here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', diff --git a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js index e5b37593174a..188226f10bd3 100644 --- a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js +++ b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js @@ -54,11 +54,12 @@ describe('create-react-class-integration', () => { 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + '- If you fetch data or perform other side effects in componentWillMount, ' + 'move this logic into componentDidMount.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: MyNativeComponent\n', {withoutStack: true}, ); @@ -76,8 +77,6 @@ describe('create-react-class-integration', () => { 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + "- If you're updating state whenever props change, " + 'move this logic into static getDerivedStateFromProps.\n' + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + @@ -85,6 +84,9 @@ describe('create-react-class-integration', () => { '- Refactor your code to not use derived state at all, as described at ' + // todo - this should be an fb.me link 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: MyNativeComponent\n', {withoutStack: true}, ); From 1ba1642a202ee4c65dff5317e9167480e0c8fc38 Mon Sep 17 00:00:00 2001 From: Sunil Pai Date: Thu, 18 Apr 2019 19:56:51 +0100 Subject: [PATCH 6/6] review stuff --- .../__tests__/ReactComponentLifeCycle-test.js | 11 +++++------ .../src/server/ReactPartialRenderer.js | 5 +++-- .../src/ReactStrictModeWarnings.js | 17 ++++++++--------- ...createReactClassIntegration-test.internal.js | 9 ++++----- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js index 7976766ee831..4a0d9f5f4149 100644 --- a/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js +++ b/packages/react-dom/src/__tests__/ReactComponentLifeCycle-test.js @@ -1410,7 +1410,7 @@ describe('ReactComponentLifeCycle', () => { ).toLowPriorityWarnDev( [ 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + - "and the old name won't work in the next major version of React.\n" + + "and the old name won't work in the next major version of React.\n\n" + 'We suggest doing one of the following:\n' + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + '- If you fetch data or perform other side effects in componentWillMount, ' + @@ -1421,22 +1421,21 @@ describe('ReactComponentLifeCycle', () => { '\nPlease update the following components: MyComponent\n', 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + - "and the old name won't work in the next major version of React.\n" + + "and the old name won't work in the next major version of React.\n\n" + 'We suggest doing one of the following:\n' + "- If you're updating state whenever props change, " + 'move this logic into static getDerivedStateFromProps.\n' + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + 'move this logic into componentDidUpdate.\n' + - '- Refactor your code to not use derived state at all, as described at ' + - // todo - this should be an fb.me link - 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + + '- Refactor your code to use memoization techniques instead of derived state. ' + + 'Learn more at: https://fb.me/react-derived-state\n' + '- To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: MyComponent\n', 'componentWillUpdate has been renamed to UNSAFE_componentWillUpdate, ' + - "and the old name won't work in the next major version of React.\n" + + "and the old name won't work in the next major version of React.\n\n" + 'We suggest doing one of the following:\n' + '- If you fetch data or perform other side effects in componentWillUpdate, ' + 'move this logic into componentDidUpdate.\n' + diff --git a/packages/react-dom/src/server/ReactPartialRenderer.js b/packages/react-dom/src/server/ReactPartialRenderer.js index fff42b69767a..cc4354424b4a 100644 --- a/packages/react-dom/src/server/ReactPartialRenderer.js +++ b/packages/react-dom/src/server/ReactPartialRenderer.js @@ -576,11 +576,12 @@ function resolve( 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + "and the old name won't work in the next major version of React.\n" + 'We suggest doing one of the following:\n' + - '- To rename all deprecated lifecycles to their new names, you can run ' + - '`npx react-codemod rename-unsafe-lifecycles ` in your project folder.\n' + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + '- If you fetch data or perform other side effects in componentWillMount, ' + 'move this logic into componentDidMount.\n' + + '- To rename all deprecated lifecycles to their new names, you can run ' + + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: %s\n' + '\nLearn about this warning, with more examples and suggestions here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', diff --git a/packages/react-reconciler/src/ReactStrictModeWarnings.js b/packages/react-reconciler/src/ReactStrictModeWarnings.js index 39cfcb41513a..acd6b438899a 100644 --- a/packages/react-reconciler/src/ReactStrictModeWarnings.js +++ b/packages/react-reconciler/src/ReactStrictModeWarnings.js @@ -142,7 +142,7 @@ if (__DEV__) { lowPriorityWarning( false, 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + - "and the old name won't work in the next major version of React.\n" + + "and the old name won't work in the next major version of React.\n\n" + 'We suggest doing one of the following:\n' + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + '- If you fetch data or perform other side effects in componentWillMount, ' + @@ -151,7 +151,7 @@ if (__DEV__) { '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: %s\n' + - '\nLearn about this warning, with more examples and suggestions here:\n' + + '\nLearn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); @@ -171,20 +171,19 @@ if (__DEV__) { lowPriorityWarning( false, 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + - "and the old name won't work in the next major version of React.\n" + + "and the old name won't work in the next major version of React.\n\n" + 'We suggest doing one of the following:\n' + "- If you're updating state whenever props change, " + 'move this logic into static getDerivedStateFromProps.\n' + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + 'move this logic into componentDidUpdate.\n' + - '- Refactor your code to not use derived state at all, as described at ' + - // todo - this should be an fb.me link - 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + + '- Refactor your code to use memoization techniques instead of derived state. ' + + 'Learn more at: https://fb.me/react-derived-state\n' + '- To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: %s\n' + - '\nLearn about this warning, with more examples and suggestions here:\n' + + '\nLearn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); @@ -204,7 +203,7 @@ if (__DEV__) { lowPriorityWarning( false, 'componentWillUpdate has been renamed to UNSAFE_componentWillUpdate, ' + - "and the old name won't work in the next major version of React.\n" + + "and the old name won't work in the next major version of React.\n\n" + 'We suggest doing one of the following:\n' + '- If you fetch data or perform other side effects in componentWillUpdate, ' + 'move this logic into componentDidUpdate.\n' + @@ -214,7 +213,7 @@ if (__DEV__) { '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + '(Note that the warning will still be logged in strict mode.)\n' + '\nPlease update the following components: %s\n' + - '\nLearn about this warning, with more examples and suggestions here:\n' + + '\nLearn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', sortedNames, ); diff --git a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js index 188226f10bd3..d22e7ee50abc 100644 --- a/packages/react/src/__tests__/createReactClassIntegration-test.internal.js +++ b/packages/react/src/__tests__/createReactClassIntegration-test.internal.js @@ -52,7 +52,7 @@ describe('create-react-class-integration', () => { expect(() => ReactNative.render(, 1)).toLowPriorityWarnDev( 'componentWillMount has been renamed to UNSAFE_componentWillMount, ' + - "and the old name won't work in the next major version of React.\n" + + "and the old name won't work in the next major version of React.\n\n" + 'We suggest doing one of the following:\n' + '- If you initialize state in componentWillMount, move this logic into the constructor.\n' + '- If you fetch data or perform other side effects in componentWillMount, ' + @@ -75,15 +75,14 @@ describe('create-react-class-integration', () => { expect(() => ReactNative.render(, 1)).toLowPriorityWarnDev( 'componentWillReceiveProps has been renamed to UNSAFE_componentWillReceiveProps, ' + - "and the old name won't work in the next major version of React.\n" + + "and the old name won't work in the next major version of React.\n\n" + 'We suggest doing one of the following:\n' + "- If you're updating state whenever props change, " + 'move this logic into static getDerivedStateFromProps.\n' + '- If you fetch data or perform other side effects in componentWillReceiveProps, ' + 'move this logic into componentDidUpdate.\n' + - '- Refactor your code to not use derived state at all, as described at ' + - // todo - this should be an fb.me link - 'https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html.\n' + + '- Refactor your code to use memoization techniques instead of derived state. ' + + 'Learn more at: https://fb.me/react-derived-state\n' + '- To rename all deprecated lifecycles to their new names, you can run ' + '`npx react-codemod rename-unsafe-lifecycles ` in your project folder. ' + '(Note that the warning will still be logged in strict mode.)\n' +