-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Convert React.createClass to React.Component #877
Conversation
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.
Please revert all the non-docs changes, and then this can land in master. #876 doesn't change the need to test, forever, createClass
classes, so tests should continue to test them.
|
||
getInitialState() { | ||
return { | ||
class WrapperComponent extends React.Component { |
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.
we definitely shouldn't change the specs here; we should continue to use createClass
.
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.
@ljharb What's the reason to continue to use createClass
? It seems to be able to replace with ES2015 classes. Is there any problems?
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.
I think it would be nice if Enzyme users don't have to install create-react-class
to use it.
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.
oops, you're right, this one isn't a spec file - this can stay as-is :-)
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.
i'd you undo the changes to the test files this can be merged
@@ -21,16 +21,16 @@ render tree. | |||
|
|||
|
|||
```jsx | |||
const MyComponent = React.createClass({ | |||
class MyComponent extends React.Component { | |||
handleClick() { | |||
... |
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.
this component doesn't really work now that it's a class because methods aren't auto bound, so if this
is used in handleClick it won't work.
do we want to have an "invalid" component as an example in the docs?
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.
good catch - let's add the best practice of a manual constructor binding to it.
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.
That makes sense. I've fixed it.
0056359
to
a9c7b66
Compare
a9c7b66
to
0dfdd84
Compare
Ok, I've reverted changes for tests. But I think it's good to use |
LGTM |
- remove createClass export from src/react-compat - add test/react-compat with createClass export - change spec files to import createClass from test/react-compat - undo changes to src/ReactWrapperComponent.jsx (use of createClass there removed in enzymejs#877 - update README with correct dependencies for react@15.5
- remove createClass export from src/react-compat - add test/react-compat with createClass export - change spec files to import createClass from test/react-compat - undo changes to src/ReactWrapperComponent.jsx (use of createClass there removed in enzymejs#877 - update README with correct dependencies for react@15.5
Thanks! |
- remove createClass export from src/react-compat - add test/react-compat with createClass export - change spec files to import createClass from test/react-compat - undo changes to src/ReactWrapperComponent.jsx (use of createClass there removed in enzymejs#877 - update README with correct dependencies for react@15.5
- remove createClass export from src/react-compat - add test/react-compat with createClass export - change spec files to import createClass from test/react-compat - undo changes to src/ReactWrapperComponent.jsx (use of createClass there removed in enzymejs#877 - update README with correct dependencies for react@15.5
- remove createClass export from src/react-compat - add test/react-compat with createClass export - change spec files to import createClass from test/react-compat - undo changes to src/ReactWrapperComponent.jsx (use of createClass there removed in enzymejs#877 - update README with correct dependencies for react@15.5
In react@15.5,
React.createClass
is deprecated, So we have to usecreate-react-class
instead. #876In this PR, I've converted
React.createClass
toReact.Component
except some tests forReact.createClass
.Should Enzyme support
create-react-class
? If it isn't necessary, I can remove allReact.createClass
from the tests.After this PR is merged, Enzyme can put
create-react-class
indevDependencies
instead ofdependencies
.