@@ -132,13 +132,11 @@ npx react-codemod replace-use-form-state <path>
132
132
Replaces usages of ReactDom.render() with createRoot(node).render().
133
133
134
134
` react-codemod ` :
135
-
136
135
``` sh
137
136
npx react-codemod replace-reactdom-render < path>
138
137
```
139
138
140
139
` codemod ` :
141
-
142
140
``` sh
143
141
npx codemod react/19/replace-reactdom-render --target < path>
144
142
```
@@ -147,6 +145,12 @@ npx codemod react/19/replace-reactdom-render --target <path>
147
145
148
146
Converts calls to ` React.createElement ` into JSX elements.
149
147
148
+ ` codemod ` :
149
+ ``` sh
150
+ npx codemod react/create-element-to-jsx --target < path>
151
+ ```
152
+
153
+ ` react-codemod ` :
150
154
``` sh
151
155
npx react-codemod create-element-to-jsx < path>
152
156
```
@@ -155,6 +159,12 @@ npx react-codemod create-element-to-jsx <path>
155
159
156
160
Renames the experimental ` unstable_handleError ` lifecycle hook to ` componentDidCatch ` .
157
161
162
+ ` codemod ` :
163
+ ``` sh
164
+ npx codemod react/error-boundaries --target < path>
165
+ ```
166
+
167
+ ` react-codemod ` :
158
168
``` sh
159
169
npx react-codemod error-boundaries < path>
160
170
```
@@ -167,6 +177,12 @@ only look at code inside of `React.createClass` calls and only update calls on
167
177
the component instance or its refs. You can use this script to update most calls
168
178
to ` getDOMNode ` and then manually go through the remaining calls.
169
179
180
+ ` codemod ` :
181
+ ``` sh
182
+ npx codemod react/findDOMNode --target < path>
183
+ ```
184
+
185
+ ` react-codemod ` :
170
186
``` sh
171
187
npx react-codemod findDOMNode < path>
172
188
```
@@ -175,6 +191,12 @@ npx react-codemod findDOMNode <path>
175
191
176
192
Converts manual function bindings in a class (e.g., ` this.f = this.f.bind(this) ` ) to arrow property initializer functions (e.g., ` f = () => {} ` ).
177
193
194
+ ` codemod ` :
195
+ ``` sh
196
+ npx codemod react/manual-bind-to-arrow --target < path>
197
+ ```
198
+
199
+ ` react-codemod ` :
178
200
``` sh
179
201
npx react-codemod manual-bind-to-arrow < path>
180
202
```
@@ -189,6 +211,12 @@ The wizard will ask for 2 options -
189
211
* ** Use arrow functions?** : converts to arrow function. Converts to ` function ` by default.
190
212
* ** Destructure props?** : will destructure props in the argument where it is safe to do so.
191
213
214
+ ` codemod ` :
215
+ ``` sh
216
+ npx codemod react/pure-component --target < path>
217
+ ```
218
+
219
+ ` react-codemod ` :
192
220
``` sh
193
221
npx react-codemod pure-component < path>
194
222
```
@@ -200,6 +228,12 @@ class transform can pick up the React component and turn it into an ES2015
200
228
class. NOTE: This currently only works if you are using the master version
201
229
(>0.13.1) of React as it is using ` React.addons.shallowCompare `
202
230
231
+ ` codemod ` :
232
+ ``` sh
233
+ npx codemod react/pure-render-mixin --target < path>
234
+ ```
235
+
236
+ ` react-codemod ` :
203
237
``` sh
204
238
npx react-codemod pure-render-mixin < path>
205
239
```
@@ -213,6 +247,12 @@ npx react-codemod pure-render-mixin <path>
213
247
214
248
Replaces ` React.PropTypes ` references with ` prop-types ` and adds the appropriate ` import ` or ` require ` statement. This codemod is intended for React 15.5+.
215
249
250
+ ` codemod ` :
251
+ ``` sh
252
+ npx codemod react/React-PropTypes-to-prop-types --target < path>
253
+ ```
254
+
255
+ ` react-codemod ` :
216
256
``` sh
217
257
npx react-codemod React-PropTypes-to-prop-types < path>
218
258
```
@@ -223,6 +263,12 @@ npx react-codemod React-PropTypes-to-prop-types <path>
223
263
224
264
Adds ` UNSAFE_ ` prefix for deprecated lifecycle hooks. (For more information about this codemod, see [ React RFC #6 ] ( https://github.com/reactjs/rfcs/pull/6 ) )
225
265
266
+ ` codemod ` :
267
+ ``` sh
268
+ npx codemod react/rename-unsafe-lifecycles --target < path>
269
+ ```
270
+
271
+ ` react-codemod ` :
226
272
``` sh
227
273
npx react-codemod rename-unsafe-lifecycles < path>
228
274
```
@@ -235,6 +281,12 @@ replaces the appropriate property accesses using `require('react-dom')`. It does
235
281
not support ES6 modules or other non-CommonJS systems. We recommend performing
236
282
the ` findDOMNode ` conversion first.
237
283
284
+ ` codemod ` :
285
+ ``` sh
286
+ npx codemod react/react-to-react-dom --target < path>
287
+ ```
288
+
289
+ ` react-codemod ` :
238
290
``` sh
239
291
npx react-codemod react-to-react-dom < path>
240
292
```
@@ -249,6 +301,12 @@ npx react-codemod react-to-react-dom <path>
249
301
250
302
Converts calls like ` React.DOM.div(...) ` to ` React.createElement('div', ...) ` .
251
303
304
+ ` codemod ` :
305
+ ``` sh
306
+ npx codemod react/React-DOM-to-react-dom-factories --target < path>
307
+ ```
308
+
309
+ ` react-codemod ` :
252
310
``` sh
253
311
npx react-codemod React-DOM-to-react-dom-factories < path>
254
312
```
@@ -257,6 +315,12 @@ npx react-codemod React-DOM-to-react-dom-factories <path>
257
315
258
316
Replaces ` View.propTypes ` references with ` ViewPropTypes ` and adds the appropriate ` import ` or ` require ` statement. This codemod is intended for ReactNative 44+.
259
317
318
+ ` codemod ` :
319
+ ``` sh
320
+ npx codemod react/ReactNative-View-propTypes --target < path>
321
+ ```
322
+
323
+ ` react-codemod ` :
260
324
``` sh
261
325
npx react-codemod ReactNative-View-propTypes < path>
262
326
```
@@ -268,6 +332,7 @@ Reorders React component methods to match the [ESLint](http://eslint.org/)
268
332
rule] ( https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md ) . (Defaults to ordering of the [ Airbnb style
269
333
guide] ( https://github.com/airbnb/javascript/blob/7684892951ef663e1c4e62ad57d662e9b2748b9e/packages/eslint-config-airbnb/rules/react.js#L122-L134 ) .
270
334
335
+ ` react-codemod ` :
271
336
``` sh
272
337
npx react-codemod sort-comp < path>
273
338
```
@@ -280,6 +345,12 @@ The wizard will ask for 1 option -
280
345
281
346
* ** 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.
282
347
348
+ ` codemod ` :
349
+ ``` sh
350
+ npx codemod react/update-react-imports --target < path>
351
+ ```
352
+
353
+ ` react-codemod ` :
283
354
``` sh
284
355
npx react-codemod update-react-imports < path>
285
356
```
0 commit comments