Skip to content

Instantly share code, notes, and snippets.

@mofas
Created March 25, 2016 16:46
Show Gist options
  • Save mofas/2bdac0c46236a90a6fb8 to your computer and use it in GitHub Desktop.
Save mofas/2bdac0c46236a90a6fb8 to your computer and use it in GitHub Desktop.
Codemod: Replace React.addons.PureRenderMixin to PureRenderMixin
{
mixins: [React.addons.OtherMixin, React.OtherMixin, CampaignMixin, React.addons.PureRenderMixin]
}
export default function transformer(file, api) {
const j = api.jscodeshift;
const {expression, statement, statements} = j.template;
return j(file.source)
.find(j.MemberExpression, {
type: "MemberExpression",
object: {
type: "MemberExpression",
object: {
name: "React"
},
property: {
name: "addons"
}
},
property: {
name: "PureRenderMixin"
}
})
.replaceWith(p => {
return j.identifier("PureRenderMixin");
})
.toSource();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment