Skip to content
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

Maybe it's a RFC #274

Closed
behnammodi opened this issue Sep 23, 2020 · 4 comments
Closed

Maybe it's a RFC #274

behnammodi opened this issue Sep 23, 2020 · 4 comments

Comments

@behnammodi
Copy link

How to change, remove or add a props to component by react-codemod for exapmle:

I have a component like this:

function Header(){
    return <div id="header"></div>
}

Now, I want to remove id props from all component so result is:

function Header(){
    return <div></div>
}

I think it can be possible like this command

npx react-codemod remove-props 'id'
@gaearon
Copy link
Member

gaearon commented Sep 23, 2020

You’d need to write your own codemod. Please search the internet for “how to write a codemod with jscodeshift”.

@gaearon gaearon closed this as completed Sep 23, 2020
@behnammodi
Copy link
Author

@gaearon Why you are angry?

@gaearon
Copy link
Member

gaearon commented Sep 23, 2020

Sorry, I didn't mean to sound angry!

I'm saying that in order to implement the functionality you want, you need to write your own codemod. This is because react-codemod is not an extensible codemod engine — it's a collection of preexisting codemods. If you want to write your own, you need to use jscodeshift. I'm suggesting that you search for a jscodeshift tutorial because it should be helpful to achieve your goals.

Does this make sense?

@behnammodi
Copy link
Author

@gaearon Thanks man, it's great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants