Convert React.createClass to React.Component#877
Conversation
|
|
||
| getInitialState() { | ||
| return { | ||
| class WrapperComponent extends React.Component { |
There was a problem hiding this comment.
we definitely shouldn't change the specs here; we should continue to use createClass.
There was a problem hiding this comment.
@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.
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.
oops, you're right, this one isn't a spec file - this can stay as-is :-)
nfcampos
left a comment
There was a problem hiding this comment.
i'd you undo the changes to the test files this can be merged
| const MyComponent = React.createClass({ | ||
| class MyComponent extends React.Component { | ||
| handleClick() { | ||
| ... |
There was a problem hiding this comment.
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.
good catch - let's add the best practice of a manual constructor binding to it.
There was a problem hiding this comment.
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.createClassis deprecated, So we have to usecreate-react-classinstead. #876In this PR, I've converted
React.createClasstoReact.Componentexcept some tests forReact.createClass.Should Enzyme support
create-react-class? If it isn't necessary, I can remove allReact.createClassfrom the tests.After this PR is merged, Enzyme can put
create-react-classindevDependenciesinstead ofdependencies.