Note that this codemod only works for React 18.3 or higher.
Should not be used if the codebase contains warnings about string refs without owners e.g.
Component "ComponentNameWithRef" contains the string ref "someStringRefName".
Support for string refs will be removed in a future major release.
This case cannot be automatically converted to an arrow function.
We ask you to manually fix this case by using useRef() or createRef() instead.
Learn more about using refs safely here:
https://reactjs.org/link/strict-mode-string-ref
For https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#deprecate-string-refs-and-remove-production-mode-_owner-field
In:
<div ref="refComponent" />;
Out:Note that this codemod only works for React 18.3 or higher.
Should not be used if the codebase contains warnings about string refs without owners e.g.
Test plan
yarn test
node bin/react-codemod.js string-refs ~/repos/react