Skip to content

Commit b4c541e

Browse files
committed
Improve warning for React.createClass (facebook#9781)
* Improve warning for `React.createClass` **what is the change?:** - Explain that this will be removed in v16.0 specifically - Mention the version number for the drop-in replacement module. - Link to docs in the blog post about how to migrate **why make this change?:** We want to make our deprecation warnings more clear and helpful. **test plan:** Visual inspection and `yarn test` **issue:** facebook#9398 * Widen range of recommended replacement module versions **what is the change?:** Instead of recommending specific versions of 'prop-types' and 'create-react-class' we ask folks to use the latest available 15.* version. **why make this change?:** The latest version of those plugins, within the 15 version, is the most likely to be stable. For example, we know that 'react-create-class' is broken for AMD builds at the current latest version, so once we release a fix then the recommended version will change. **test plan:** Visual inspection Also fixed some tests. * Fix typos and things **what is the change?:** - `migrade` -> `migrate` - `15.* prop-types package` -> `v15.* prop-types package` **why make this change?:** Correctness **test plan:** `yarn test` and visual inspection
1 parent 7427d56 commit b4c541e

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/isomorphic/React.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ if (__DEV__) {
112112
didWarnPropTypesDeprecated,
113113
'Accessing PropTypes via the main React package is deprecated,' +
114114
' and will be removed in React v16.0.' +
115-
' Use the prop-types package from npm instead.' +
116-
' Version 15.5.10 provides a drop-in replacement.' +
115+
' Use the latest available v15.* prop-types package from npm instead.' +
117116
' For info on usage, compatibility, migration and more, see ' +
118117
'https://fb.me/prop-types-docs',
119118
);
@@ -126,10 +125,12 @@ if (__DEV__) {
126125
get: function() {
127126
lowPriorityWarning(
128127
warnedForCreateClass,
129-
'React.createClass is no longer supported. Use a plain JavaScript ' +
130-
"class instead. If you're not yet ready to migrate, " +
131-
'create-react-class is available on npm as a temporary, ' +
132-
'drop-in replacement.',
128+
'Accessing createClass via the main React package is deprecated,' +
129+
' and will be removed in React v16.0.' +
130+
" Use a plain JavaScript class instead. If you're not yet " +
131+
'ready to migrate, create-react-class v15.* is available ' +
132+
'on npm as a temporary, drop-in replacement. ' +
133+
'For more info see https://fb.me/react-create-class',
133134
);
134135
warnedForCreateClass = true;
135136
return createReactClass;

src/isomorphic/__tests__/React-test.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ describe('React', () => {
4545
expect(createClass).not.toBe(undefined);
4646
expect(console.warn.calls.count()).toBe(1);
4747
expect(console.warn.calls.argsFor(0)[0]).toContain(
48-
'React.createClass is no longer supported. Use a plain ' +
49-
"JavaScript class instead. If you're not yet ready to migrate, " +
50-
'create-react-class is available on npm as a temporary, ' +
51-
'drop-in replacement.',
48+
'Warning: Accessing createClass via the main React package is ' +
49+
'deprecated, and will be removed in React v16.0. ' +
50+
"Use a plain JavaScript class instead. If you're not yet ready " +
51+
'to migrate, create-react-class v15.* is available on npm as ' +
52+
'a temporary, drop-in replacement. ' +
53+
'For more info see https://fb.me/react-create-class',
5254
);
5355
});
5456

@@ -61,10 +63,9 @@ describe('React', () => {
6163
expect(console.warn.calls.argsFor(0)[0]).toContain(
6264
'Warning: Accessing PropTypes via the main React package is ' +
6365
'deprecated, and will be removed in React v16.0. ' +
64-
'Use the prop-types package from npm instead. ' +
65-
'Version 15.5.10 provides a drop-in replacement. ' +
66-
'For info on usage, compatibility, migration and more, ' +
67-
'see https://fb.me/prop-types-docs',
66+
'Use the latest available v15.* prop-types package from ' +
67+
'npm instead. For info on usage, compatibility, migration ' +
68+
'and more, see https://fb.me/prop-types-docs',
6869
);
6970
});
7071
});

0 commit comments

Comments
 (0)