copy-paste-component for Visual Studio Code
An extension to create components, by copying and pasting existing ones. It integrates the copy-paste-component tool directly inside Visual Studio Code.
If you have the structure below:
src/components/App/App.js
src/components/App/App.test.js
src/components/App/App.stories.js
src/components/App/index.js
when you run the extension, it will create the following structure, replacing occurrences of the word App
inside the files to NewApp
:
src/components/NewApp/NewApp.js
src/components/NewApp/NewApp.test.js
src/components/NewApp/NewApp.stories.js
src/components/NewApp/index.js
Just right click the component that you would like to copy and click Copy and paste component
. After this, you will be prompted with a couple of questions about the new component, and then it will generate a structure that is the same as the one that the selected component uses, but it will change the filename to the one you provided.
It will also look inside the file for occurrences of the filename, and if it finds, it replaces with the one you provided.
So, given the following file:
import React from "react"
const App = () => <div>Hello World</div>
export default App
Becomes the following:
import React from "react"
const NewApp = () => <div>Hello World</div>
export default NewApp
- copy-paste-component A tool to create components, by copying and pasting existing ones.
See Change log.
MIT