Skip to content

Commit

Permalink
Improve deprecation warnings by more info and links (facebook#9768)
Browse files Browse the repository at this point in the history
* Improve deprecation warnings by more info and links

**what is the change?:**
Updates the warnings for -
 - `React.createMixin` (was never implemented!)
 - `React.PropTypes`
 - `React.createClass`
 - `React.DOM.*`

We never added the warning for `React.createClass` to the 15.5 line, so
a follow-up PR will add that, with a link to docs etc.

Does *not* update the older warnings for -
 - Factory.type
 - 'isMounted' and 'replaceState'
 - ReactPerf

We could do a second pass if we want to improve those three warnings, but for now I don't think they are as hi-pri.

Still TODO:
 - Do an initial release of the [`react-addons-dom-factories`](https://github.com/facebook/react/tree/master/packages/react-dom-factories#react-addons-dom-factories) package on npm, making it 1.0.
 - Improve the docs for `react-addons-dom-factories` adding documentation and mention the [codemod](https://github.com/reactjs/react-codemod/blob/master/transforms/React-DOM-to-react-dom-factories.js)

**why make this change?:**
 - We want to make updating as easy as possible. Warning messages should increase clarity, and in the past they have caused confusion.

**test plan:**
`yarn test` and running these messages past some folks who use React.

**issue:**
facebook#9398

* Rephrase deprecation messages for clarity

**what is the change?:**
We rephrased the deprecation messages to clarify that
 - these APIs are currently deprecated
 - they will be removed in React v16.0

The previous wording implied that they would be deprecated in v16.0.

**why make this change?:**
To make the messages easier to understand.

**test plan:**
Visual inspection
  • Loading branch information
flarnie committed Jun 7, 2017
1 parent 3911544 commit cc89cf5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/isomorphic/React.js
Expand Up @@ -59,8 +59,10 @@ if (__DEV__) {
createMixin = function(mixin) {
lowPriorityWarning(
warnedForCreateMixin,
'React.createMixin is deprecated and should not be used. You ' +
'can use this mixin directly instead.',
'React.createMixin is deprecated and should not be used. ' +
'In React v16.0, it will be removed. ' +
'You can use this mixin directly instead. ' +
'See https://fb.me/createmixin-was-never-implemented for more info.',
);
warnedForCreateMixin = true;
return mixin;
Expand Down Expand Up @@ -109,8 +111,12 @@ if (__DEV__) {
get() {
lowPriorityWarning(
didWarnPropTypesDeprecated,
'Accessing PropTypes via the main React package is deprecated. Use ' +
'the prop-types package from npm instead.',
'Accessing PropTypes via the main React package is deprecated,' +
' and will be removed in React v16.0.' +
' Use the prop-types package from npm instead.' +
' Version 15.5.10 provides a drop-in replacement.' +
' For info on usage, compatibility, migration and more, see ' +
'https://fb.me/prop-types-docs',
);
didWarnPropTypesDeprecated = true;
return ReactPropTypes;
Expand All @@ -129,8 +135,10 @@ if (__DEV__) {
lowPriorityWarning(
false,
'Accessing factories like React.DOM.%s has been deprecated ' +
'and will be removed in the future. Use the ' +
'react-addons-dom-factories package instead.',
'and will be removed in v16.0+. Use the ' +
'react-addons-dom-factories package instead. ' +
' Version 1.0 provides a drop-in replacement.' +
' For more info, see https://fb.me/react-addons-dom-factories',
factory,
);
warnedForFactories = true;
Expand Down

0 comments on commit cc89cf5

Please sign in to comment.