-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
RFC 6: Deprecate unsafe lifecycles #12028
Changes from 17 commits
e709e30
404944e
bd300b3
2868176
8679926
64f27d7
1047182
035c220
8d0e001
b71ca93
09c39d0
286df77
b699543
68f2fe7
2d9f75d
8f125b7
1d3e3d5
d95ec49
b940938
6cd0a8e
7572667
361a2cf
8178d52
8d67e27
53770c3
3772ee2
4dfa6e1
5609031
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @emails react-core | ||
*/ | ||
|
||
'use strict'; | ||
|
||
let React; | ||
let ReactDOM; | ||
let ReactFeatureFlags; | ||
|
||
describe('ReactComponentLifeCycle', () => { | ||
beforeEach(() => { | ||
jest.resetModules(); | ||
|
||
ReactFeatureFlags = require('shared/ReactFeatureFlags'); | ||
ReactFeatureFlags.warnAboutDeprecatedLifecycles = true; | ||
|
||
React = require('react'); | ||
ReactDOM = require('react-dom'); | ||
}); | ||
|
||
// TODO (RFC #6) Merge this back into ReactComponentLifeCycles-test once | ||
// the 'warnAboutDeprecatedLifecycles' feature flag has been removed. | ||
it('warns about deprecated unsafe lifecycles', function() { | ||
class MyComponent extends React.Component { | ||
componentWillMount() {} | ||
componentWillReceiveProps() {} | ||
componentWillUpdate() {} | ||
render() { | ||
return null; | ||
} | ||
} | ||
|
||
const container = document.createElement('div'); | ||
expect(() => ReactDOM.render(<MyComponent x={1} />, container)).toWarnDev([ | ||
'Warning: MyComponent: componentWillMount() is deprecated and will be ' + | ||
'removed in the next major version. ' + | ||
'Please use UNSAFE_componentWillMount() instead.', | ||
]); | ||
|
||
expect(() => ReactDOM.render(<MyComponent x={2} />, container)).toWarnDev([ | ||
'Warning: MyComponent: componentWillReceiveProps() is deprecated and ' + | ||
'will be removed in the next major version. ' + | ||
'Please use UNSAFE_componentWillReceiveProps() instead.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this one, we should call out
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! Thanks for the improved wording suggestions! I've made the wording improvements in 3772ee2. |
||
'Warning: MyComponent: componentWillUpdate() is deprecated and will be ' + | ||
'removed in the next major version. ' + | ||
'Please use UNSAFE_componentWillUpdate() instead.', | ||
]); | ||
|
||
// Dedupe check (instantiate and update) | ||
ReactDOM.render(<MyComponent key="new" x={1} />, container); | ||
ReactDOM.render(<MyComponent key="new" x={2} />, container); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like this?
(link) can point to some fburl that we write later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now the link can be your RFC :)