HearTao/ts-react-hooks-tools

[Feature Request] "Extract to component" refactor

Opened this issue · 1 comments

Like the built-in "extract to function" refactor, I propose an "extract to component" refactor:

  1. Select some jsx elements
  2. Invoke the "extract to component" refactor
  3. It automatically analyzes dependencies of selected code, generates a new component with these props, and replaces selection with an element of the newly created component type.

It may have some variants:

  1. Extract to component in same module
  2. Extract to component in a new file

Multiples by:

  1. Extract to functional component
  2. Extract to functional component wrapped with React.memo
  3. Extract to class component (maybe not needed as class component is not mainstream anymore)

It's a bit complex. But a good idea.