react-codemod
react-codemod copied to clipboard
React codemod scripts
When an import is defined as ``` import React, { useState } from 'react' ``` (usually due to automatically added imports) The update-react-imports codemod transforms it to ``` import {...
Seeing this error when running rename-unsafe-lifecycles: ``` Error: did not recognize object of type "ImportExpression" at Object.getFieldNames (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/ast-types/lib/types.js:701:19) at getSortedChildNodes (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:50:23) at getSortedChildNodes (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:63:9) at decorateComment (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:73:22) at decorateComment (/Users/wes/.npm/_npx/76919/lib/node_modules/react-codemod/node_modules/recast/lib/comments.js:84:13)...
Possible Add - **Updates to Client Rendering API (React 18)** ``` // Before import { render } from 'react-dom'; const container = document.getElementById('app'); render(, container); ``` ``` // After import...
During the bump of react x -> y, This changes import statements
I assume this is accidental but given that this is an MIT-licensed repository all files under it should also be MIT no?
It could be interesting to add support for superType annotations of Flow. It is quite common in many projects and the transformation is simple.
When running the pure-component codemod on a typescript file ``` // TransformTest.tsx import React from 'react'; class TransformTest extends React.Component { render() { return I've too much class; } }...
**What's the problem this PR addresses?** Using `require.resolve('.bin/jscodeshift')` relies on an implementation detail that isn't guaranteed to exist (Yarn PnP) or point to the expected version of `jscodeshift` **How did...
Run : `npx react-codemod update-react-imports` babel version: ``` "@babel/core": "^7.12.3", "@babel/preset-react": "^7.12.1", ``` It report: 
I have `PureComponent` only with `static propTypes` and `render` I run ``` npx react-codemod pure-component path_to_component ``` and I get error ``` Unable to destructure ComponentName props. ERR path_to_component Transformation...