-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react/19/replace-default-props does not add ES6 default parameters #321
Comments
@DmytroHryshyn I saw you were contributing the most to the codemod. Can you look into that 🙏 ? |
Thanks for reporting this @quarhodron! @DmytroHryshyn will be away for some time. @arybitskiy can you please take a look at this? |
@mohab-sameh do you think @arybitskiy will be able to still look at it because it seems he hasn't done any commits recently |
I'm also seeing the same issue. Initially the codemod was returning "No changes were made during the codemod run.". I think this is because much of our code is in the following format: const defaultProps = {
size: '16px',
color: 'blue',
};
const Button = ({ size, color }) => {
return <button style={{ color, fontSize: size }}>Click me</button>;
}
Button.defaultProps = defaultProps; If I manually remove the |
@amirabbas-gh and I pushed a fix to the registry. try it out and let me know if there’s still an issue. Just run:
@rickhanlonii, we should be good to close this issue now. (fyi, this codemod was never checked into this repo or the official migration guide. It lives here: https://github.com/codemod-com/Commons/tree/main/react/19/replace-default-props and in the registry) |
The example nicely shows that default props from
defaultProps
will be added to the component props as shown in this example https://github.com/codemod-com/codemod/tree/main/packages/codemods/react/19/replace-default-props.However, when I am running
npx codemod react/19/replace-default-props
it only removesdefaultProps
and not adding default props to destructured component props. Even when I tried to just have the exact code from the mentioned example, it only removed this block:and the rest was left untouched
I worked on codemod in version
0.13.3
.Tested on project either in pure
js
or TS withtsx
files.Tested either on Node 18.17.1 or 20.15.1.
Tested on React either 18.3.1 and 18.2.0. Not sure if it matters.
All of them resulted in removing only
defaultProps
and not adding ES6 default parameters to component.The text was updated successfully, but these errors were encountered: