@@ -132,13 +132,11 @@ npx react-codemod replace-use-form-state <path>
132132Replaces usages of ReactDom.render() with createRoot(node).render().
133133
134134` react-codemod ` :
135-
136135``` sh
137136npx react-codemod replace-reactdom-render < path>
138137```
139138
140139` codemod ` :
141-
142140``` sh
143141npx codemod react/19/replace-reactdom-render --target < path>
144142```
@@ -147,6 +145,12 @@ npx codemod react/19/replace-reactdom-render --target <path>
147145
148146Converts calls to ` React.createElement ` into JSX elements.
149147
148+ ` codemod ` :
149+ ``` sh
150+ npx codemod react/create-element-to-jsx --target < path>
151+ ```
152+
153+ ` react-codemod ` :
150154``` sh
151155npx react-codemod create-element-to-jsx < path>
152156```
@@ -155,6 +159,12 @@ npx react-codemod create-element-to-jsx <path>
155159
156160Renames the experimental ` unstable_handleError ` lifecycle hook to ` componentDidCatch ` .
157161
162+ ` codemod ` :
163+ ``` sh
164+ npx codemod react/error-boundaries --target < path>
165+ ```
166+
167+ ` react-codemod ` :
158168``` sh
159169npx react-codemod error-boundaries < path>
160170```
@@ -167,6 +177,12 @@ only look at code inside of `React.createClass` calls and only update calls on
167177the component instance or its refs. You can use this script to update most calls
168178to ` getDOMNode ` and then manually go through the remaining calls.
169179
180+ ` codemod ` :
181+ ``` sh
182+ npx codemod react/findDOMNode --target < path>
183+ ```
184+
185+ ` react-codemod ` :
170186``` sh
171187npx react-codemod findDOMNode < path>
172188```
@@ -175,6 +191,12 @@ npx react-codemod findDOMNode <path>
175191
176192Converts manual function bindings in a class (e.g., ` this.f = this.f.bind(this) ` ) to arrow property initializer functions (e.g., ` f = () => {} ` ).
177193
194+ ` codemod ` :
195+ ``` sh
196+ npx codemod react/manual-bind-to-arrow --target < path>
197+ ```
198+
199+ ` react-codemod ` :
178200``` sh
179201npx react-codemod manual-bind-to-arrow < path>
180202```
@@ -189,6 +211,12 @@ The wizard will ask for 2 options -
189211* ** Use arrow functions?** : converts to arrow function. Converts to ` function ` by default.
190212* ** Destructure props?** : will destructure props in the argument where it is safe to do so.
191213
214+ ` codemod ` :
215+ ``` sh
216+ npx codemod react/pure-component --target < path>
217+ ```
218+
219+ ` react-codemod ` :
192220``` sh
193221npx react-codemod pure-component < path>
194222```
@@ -200,6 +228,12 @@ class transform can pick up the React component and turn it into an ES2015
200228class. NOTE: This currently only works if you are using the master version
201229(>0.13.1) of React as it is using ` React.addons.shallowCompare `
202230
231+ ` codemod ` :
232+ ``` sh
233+ npx codemod react/pure-render-mixin --target < path>
234+ ```
235+
236+ ` react-codemod ` :
203237``` sh
204238npx react-codemod pure-render-mixin < path>
205239```
@@ -213,6 +247,12 @@ npx react-codemod pure-render-mixin <path>
213247
214248Replaces ` React.PropTypes ` references with ` prop-types ` and adds the appropriate ` import ` or ` require ` statement. This codemod is intended for React 15.5+.
215249
250+ ` codemod ` :
251+ ``` sh
252+ npx codemod react/React-PropTypes-to-prop-types --target < path>
253+ ```
254+
255+ ` react-codemod ` :
216256``` sh
217257npx react-codemod React-PropTypes-to-prop-types < path>
218258```
@@ -223,6 +263,12 @@ npx react-codemod React-PropTypes-to-prop-types <path>
223263
224264Adds ` UNSAFE_ ` prefix for deprecated lifecycle hooks. (For more information about this codemod, see [ React RFC #6 ] ( https://github.com/reactjs/rfcs/pull/6 ) )
225265
266+ ` codemod ` :
267+ ``` sh
268+ npx codemod react/rename-unsafe-lifecycles --target < path>
269+ ```
270+
271+ ` react-codemod ` :
226272``` sh
227273npx react-codemod rename-unsafe-lifecycles < path>
228274```
@@ -235,6 +281,12 @@ replaces the appropriate property accesses using `require('react-dom')`. It does
235281not support ES6 modules or other non-CommonJS systems. We recommend performing
236282the ` findDOMNode ` conversion first.
237283
284+ ` codemod ` :
285+ ``` sh
286+ npx codemod react/react-to-react-dom --target < path>
287+ ```
288+
289+ ` react-codemod ` :
238290``` sh
239291npx react-codemod react-to-react-dom < path>
240292```
@@ -249,6 +301,12 @@ npx react-codemod react-to-react-dom <path>
249301
250302Converts calls like ` React.DOM.div(...) ` to ` React.createElement('div', ...) ` .
251303
304+ ` codemod ` :
305+ ``` sh
306+ npx codemod react/React-DOM-to-react-dom-factories --target < path>
307+ ```
308+
309+ ` react-codemod ` :
252310``` sh
253311npx react-codemod React-DOM-to-react-dom-factories < path>
254312```
@@ -257,6 +315,12 @@ npx react-codemod React-DOM-to-react-dom-factories <path>
257315
258316Replaces ` View.propTypes ` references with ` ViewPropTypes ` and adds the appropriate ` import ` or ` require ` statement. This codemod is intended for ReactNative 44+.
259317
318+ ` codemod ` :
319+ ``` sh
320+ npx codemod react/ReactNative-View-propTypes --target < path>
321+ ```
322+
323+ ` react-codemod ` :
260324``` sh
261325npx react-codemod ReactNative-View-propTypes < path>
262326```
@@ -268,6 +332,7 @@ Reorders React component methods to match the [ESLint](http://eslint.org/)
268332rule] ( https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md ) . (Defaults to ordering of the [ Airbnb style
269333guide] ( https://github.com/airbnb/javascript/blob/7684892951ef663e1c4e62ad57d662e9b2748b9e/packages/eslint-config-airbnb/rules/react.js#L122-L134 ) .
270334
335+ ` react-codemod ` :
271336``` sh
272337npx react-codemod sort-comp < path>
273338```
@@ -280,6 +345,12 @@ The wizard will ask for 1 option -
280345
281346* ** Destructure namespace imports as well?** : If chosen, * namespace* imports like ` import * as React ` will * also* be converted. By default, it's false, so only default imports (` import React ` ) are converted.
282347
348+ ` codemod ` :
349+ ``` sh
350+ npx codemod react/update-react-imports --target < path>
351+ ```
352+
353+ ` react-codemod ` :
283354``` sh
284355npx react-codemod update-react-imports < path>
285356```
0 commit comments