Skip to content
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

Improve warning for React.createClass #9781

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/isomorphic/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ if (__DEV__) {
didWarnPropTypesDeprecated,
'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.' +
' Use the latest available v15.* prop-types package from npm instead.' +
' For info on usage, compatibility, migration and more, see ' +
'https://fb.me/prop-types-docs',
);
Expand All @@ -126,10 +125,12 @@ if (__DEV__) {
get: function() {
lowPriorityWarning(
warnedForCreateClass,
'React.createClass is no longer supported. Use a plain JavaScript ' +
"class instead. If you're not yet ready to migrate, " +
'create-react-class is available on npm as a temporary, ' +
'drop-in replacement.',
'Accessing createClass via the main React package is deprecated,' +
' and will be removed in React v16.0.' +
" Use a plain JavaScript class instead. If you're not yet " +
'ready to migrate, create-react-class v15.* is available ' +
'on npm as a temporary, drop-in replacement. ' +
'For more info see https://fb.me/react-create-class',
);
warnedForCreateClass = true;
return createReactClass;
Expand Down
17 changes: 9 additions & 8 deletions src/isomorphic/__tests__/React-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ describe('React', () => {
expect(createClass).not.toBe(undefined);
expect(console.warn.calls.count()).toBe(1);
expect(console.warn.calls.argsFor(0)[0]).toContain(
'React.createClass is no longer supported. Use a plain ' +
"JavaScript class instead. If you're not yet ready to migrate, " +
'create-react-class is available on npm as a temporary, ' +
'drop-in replacement.',
'Warning: Accessing createClass via the main React package is ' +
'deprecated, and will be removed in React v16.0. ' +
"Use a plain JavaScript class instead. If you're not yet ready " +
'to migrate, create-react-class v15.* is available on npm as ' +
'a temporary, drop-in replacement. ' +
'For more info see https://fb.me/react-create-class',
);
});

Expand All @@ -61,10 +63,9 @@ describe('React', () => {
expect(console.warn.calls.argsFor(0)[0]).toContain(
'Warning: 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',
'Use the latest available v15.* prop-types package from ' +
'npm instead. For info on usage, compatibility, migration ' +
'and more, see https://fb.me/prop-types-docs',
);
});
});