Skip to content

Commit

Permalink
react-create-class -> create-react-class
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite authored and flarnie committed May 25, 2017
1 parent 3f62cd5 commit 4c9c859
Show file tree
Hide file tree
Showing 5 changed files with 455 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"coffee-script": "^1.8.0",
"core-js": "^2.2.1",
"coveralls": "^2.11.6",
"create-react-class": "15.5.0",
"create-react-class": "^15.5.0",
"del": "^2.0.2",
"derequire": "^2.0.3",
"eslint": "^3.10.2",
Expand Down
14 changes: 14 additions & 0 deletions src/isomorphic/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,20 @@ if (__DEV__) {
return ReactPropTypes;
},
});

Object.defineProperty(React, 'createClass', {
get: function() {
warning(
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.',
);
didWarnPropTypesDeprecated = true;
return ReactPropTypes;
},
});
}

// React.DOM factories are deprecated. Wrap these methods so that
Expand Down
14 changes: 14 additions & 0 deletions src/isomorphic/__tests__/React-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,18 @@ describe('React', () => {
'React.createMixin is deprecated and should not be used',
);
});

it('should warn once when attempting to access React.createClass', () => {
spyOn(console, 'error');
let createClass = React.createClass;
createClass = React.createClass;
expect(createClass).toBe(undefined);
expectDev(console.error.calls.count()).toBe(1);
expectDev(console.error.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.',
);
});
});
Loading

0 comments on commit 4c9c859

Please sign in to comment.