{"componentChunkName":"component---src-components-blog-template-js","path":"/blog/introduction-to-react-app/","result":{"data":{"markdownRemark":{"frontmatter":{"title":"Introduction to React App","date":"2019-03-15"},"html":"<p>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.\nThere are even ways to play around with React without creating the app, one of which I found quite useful is <a href=\"https://codesandbox.io/s/new\">codesandbox</a>.</p>\n<h4>Create React App</h4>\n<p>The popular method of setting a React app is <a href=\"https://github.com/facebook/create-react-app\">Create React App</a> 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.</p>\n<p>To set it up, you would need <code class=\"language-text\">Node.js 5.2</code> or higher installed, then use either <code class=\"language-text\">npm</code>, <code class=\"language-text\">npx</code> or <code class=\"language-text\">yarn</code>. 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 <code class=\"language-text\">create-react-app</code> package globally and maintaining its version, we can use npx to execute it using its latest version.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">npx create<span class=\"token operator\">-</span>react<span class=\"token operator\">-</span>app react<span class=\"token operator\">-</span>app<span class=\"token operator\">-</span>name</code></pre></div>\n<br />\n<h4>Scripts</h4>\n<p>Once it is finished installing, we can change the directory to the app name created, then we can run scripts such as:</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">npm start</code></pre></div>\n<p>Run the app in development mode using the live development server. To view it open a browser and go to <code class=\"language-text\">http://localhost:3000</code>\nIn here, everytime we make changes to the code file, the page will be automatically reloaded.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">npm test</code></pre></div>\n<p>Run the test script in watch mode where we can give inputs to navigate the test process.</p>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre class=\"language-javascript\"><code class=\"language-javascript\">npm run build</code></pre></div>\n<p>Build the app in <code class=\"language-text\">build</code> folder that is ready for deployment. The build version file (bundle) is minified and optimised for performance.</p>"}},"pageContext":{"slug":"/introduction-to-react-app/"}},"staticQueryHashes":[]}