Skip to content

Add refactoring action to export selected JSX code as stateless component #15090

Open
@rosieks

Description

@rosieks

Please add refactoring action that will improve productivity while working with JSX/TSX. Suppose that I have the following code:

class Page extends React.Component {
    render() {
        return (
            <div>
                <h1>{this.props.header}</h1>
            </div>
        );
    }
}

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:

const NewComponent = ({ header }) => (<h1>{header}</h1>);

The selected text would be replaced with that:

<NewComponent header={this.props.header} />

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions