-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Add refactoring action to export selected JSX code as stateless component #15090
Comments
It would also be fine if it can convert component class into stateless component if possible and reverse convertion class Page extends React.Component<PageProps, {}> {
render() {
return (
<div>
<h1>{this.props.header}</h1>
</div>
);
}
}
// refactor converts to
function Page({header}: PageProps) {
return (
<div>
<h1>{header}</h1>
</div>
);
} I think it possible to do with language service's plugin |
I have a partially working version of this, but it was hard to get this working without #15868. The problem was accomodating |
@DanielRosenwasser - is it because after extracting selected text to stateless function you also want to generate |
This should no longer be blocked, so if you already have a quickfix, let's see it. 😄 |
This is very similar to #25891. I made a proposal here: #25891 (comment) |
Please add refactoring action that will improve productivity while working with JSX/TSX. Suppose that I have the following code:
I would like to select line with
<h1>
and chose from context menu "Extract to stateless component". And that would create the following stateless component:The selected text would be replaced with that:
The text was updated successfully, but these errors were encountered: