2019-03-15
I found that there are numerous methods to create a React App, from the free of nitty-gritty configuration to the most heavily configured one. There are even ways to play around with React without creating the app, one of which I found quite useful is codesandbox.
The popular method of setting a React app is Create React App created by Facebook, a fully configured environment packed with everything you need to build a React app. It comes with a live development server, test scripts, auto-reload with Webpack, ES6, and even linter to prevent mistakes in code.
To set it up, you would need Node.js 5.2
or higher installed, then use either npm
, npx
or yarn
. I personally like to use npx since it is very convenient. npx is an npm package runner which is great at executing one-off command. In this case, rather than installing create-react-app
package globally and maintaining its version, we can use npx to execute it using its latest version.
npx create-react-app react-app-name
Once it is finished installing, we can change the directory to the app name created, then we can run scripts such as:
npm start
Run the app in development mode using the live development server. To view it open a browser and go to http://localhost:3000
In here, everytime we make changes to the code file, the page will be automatically reloaded.
npm test
Run the test script in watch mode where we can give inputs to navigate the test process.
npm run build
Build the app in build
folder that is ready for deployment. The build version file (bundle) is minified and optimised for performance.