react-pure-to-class
react-pure-to-class copied to clipboard
Class to Pure
Thank you for this plugin! It's awesome. I have the additional issue of where a component is written as a class but should be a pure function. Would you consider adding a reverse refactor?
I found react-codemod from Facebook has that transformation in the transforms/PureComponent file. so all would need to do is require that package and require the PureComponent file.
Hey! Yes, I know about that codemod. I was thinking about reverse transformation myself a few months ago, but consequently forgot about it =) I'll see if I can incorporate their code.
So, I tried incorporating the codemod, at it works, but it doesnt support all the options that PureToClass has, so you can't transform the same piece of code back and forth which is what i'd like to. It only transforms if you extend from React.Component
and doens't transform if you have anything in you class besides render method, even an empty constructor like so:
constructor(props) {
super(props);
}
Seems like i'll have to either modify their code or write my own. We'll try asap.
Or you can try this plugin https://marketplace.visualstudio.com/items?itemName=wix.glean