extract-component
Provides an Extract Component refactoring task. Takes a selected JSX snippet and extracts it into a new component.
bspaulding 145 0 1.0.1 MIT GitHub

extract-component package

Refactoring task to extract a portion of JSX as a new component.

TODO

x Prettier indentation on both removed and inserted text / Look for var refs and transform to props - done-ish, currently looks only for MemberExpression names would be better if became:

		const Component = ({ src }) => (
		<Image src={src}/>
	  )

	although this would introduce complexity and probably new edge cases
  • grab jsx component imports
  • restore focus to active editor on modal close
    • this should be working, not sure why it isn't
  • save the new component file immediately?
  • add new import last?
  • Allow for leaving children in place, only extracting wrapping element as component
  • Leave children by default, by UI option, or by separate command?