Comments (6)
@developit Thanks for feedback. I started this as an experiment to learn more about AST/codemods and glad that you found it.
Your ES class transforms looks a lot cleaner than what I had. I actually just pushed up an update which also preserved the JSX in the render()
call and converted the createClass
to a pure function. Your ES classes look a lot better. Did you want to submit a PR for this?
from preact-codemod.
Could do, though I think the pure function is a nicer approach. I was thinking maybe the codemod could check if a createClass()
component was pure or impure and choose the output type (pure function vs class) appropriately... should be as simple as checking for the existence of properties other than render()
, defaultProps
and displayName
.
from preact-codemod.
@developit I've just merged in this functionality based on your example with some minor adjustments which is moving the literals inside the ES6 constructor where necessary.
See here: https://astexplorer.net/#/M4CGKhVyp0
from preact-codemod.
@vutran looks good! How come you moved the literals into the constructor? That's already how they work in ES6: https://goo.gl/imGiI5
Work either way though! One thing to watch out for: it might be worth passing (props, context)
to super()
so that this.props
and this.context
are defined in case they are referenced prior to the constructor being finished evaluation. (example: http://astexplorer.net/#/Pcp2Q5NFLq/11)
from preact-codemod.
@developit Apologies been really busy at work and another app at the moment. I've just deployed the updated constructor()
and super()
calls.
from preact-codemod.
Awesome!
from preact-codemod.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from preact-codemod.