How can I import projects (React) from a public sandbox to a local project folder?
There are a lot of examples on StackOverflow written in CodeSandbox for React, and I am wondering how to download the files into a local folder that I could edit and alter in an editor like Atom.
For example, I want to use the Sandbox example (https://codesandbox.io/s/k9r9692m77) given as an answer in this question (Add and remove data to table - React).
The only way I can think of doing this is by a similar process below:
npx create-react-app my-app
cd my-app
Then copying and pasting all the files individually into my-app
and doing npm install
, then npm start
. But I do not feel this is an efficient way to do it, especially when the projects have a lot of individual files.
I have not worked much with React, or Sandbox, so I get a little confused when in Sandbox I do not see an App.js file for a React project, yet the project still runs (I am guessing this is through the index.js file). This might only apply to the Sandbox code I linked in this question.
Let me know if further information is needed.
You can download the project as a zip
- Extract it
- open in terminal
- npm i
- npm run start and it should pop up in your browser at localhost:3000
In the projects package.json, there is a field called main which you can use to set the entry point of the application. This can be used instead of having App.js. More information available here