mirror of
https://github.com/facebook/react.git
synced 2026-02-25 13:13:03 +00:00
react-codemod
This repository contains a collection of codemod scripts based on JSCodeshift that help update React APIs.
Setup & Run
npm install -g react-codemodreact-codemod <codemod-script> <file>- Use the
-doption for a dry-run and use-pto print the output for comparison
Included Scripts
findDOMNode.js updates this.getDOMNode() or this.refs.foo.getDOMNode()
calls inside of React.createClass components to React.findDOMNode(foo). Note
that it will only look at code inside of React.createClass calls and only
update calls on the component instance or its refs. You can use this script to
update most calls to getDOMNode and then manually go through the remaining
calls.
react-codemod findDOMNode <file>
Recast Options
Options to recast's printer can be provided
through the printOptions command line argument
react-codemod class <file> --printOptions='{"quote":"double"}'