- Notifications
You must be signed in to change notification settings - Fork 300
Add pure component transform #1
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
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
FWIW: tests look like they are running for me, but there are a few pre-existing failures |
Oh actually I bet it isn't wouldn't be running - add your case in https://github.com/reactjs/react-codemod/blob/master/test/__tests__/transform-tests.js. That won't solve general issues with jest not running but will make sure your test does run when you work that out. |
yeah I'll take a look soon-ish at why the tests are failing. @thejameskyle awesome work! :) |
transforms/pure-component.js Outdated
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 should do a didTransform
kinda thing and only return a non-null value if the .size()
of this collection is > 0
.
See https://github.com/reactjs/react-codemod/blob/master/transforms/pure-render-mixin.js#L172
This is a good start! The tests should be fixed on master now.
|
There is also the Useful for collecting statistics about your codebase / codemod. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
44cfe5d
to 5d98bf0
Compare Threw together a Babel plugin as well. Thought it'd be a useful optimization to run in a production build https://github.com/thejameskyle/babel-plugin-react-pure-components |
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 variant should probably take the argument
of the ReturnStatement
if the length of renderBody.body
is one and it only contains a return statement :)
Yay! Would you mind flattening your commits into a single one before I merge? :) |
8dc6e0d
to f90ccb7
Compare Dammit, I missed this because github doesn't notify me about force pushes to PRs. |
Sorry, I knew that, should've pinged you. |
This is all I have time for now so I'm throwing it up into a PR.
Trying to figure out why Jest won't run.Re: https://twitter.com/cpojer/status/656602748050247680