Hello React #1: Creating a Single Page Application with React

Table of contents
Reading Time: 2 minutes

Few days ago we were looking for a JavaScript library which is flexible and can be used in a variety of projects. Basically, something with which we can create new apps, or introduce into an existing project without rewriting it. However, we came across React, a JavaScript library for building user interfaces and AngularJS, a JavaScript MVW Framework.

Before we start creating a single page application, we need to install NodeJS and NPM. After you have installed them, we are ready to create our first application with React.

Create React App is the best way to start building a new React single page application. So, we will be using it to create out first single page application with React.

sudo npm install -g create-react-app
create-react-app hello-world
cd hello-world
npm start

create-react-app will create a hello-world application for us with following directory structure.

hello-world/
  README.md
  node_modules/
  package.json
  .gitignore
  public/
    favicon.ico
    index.html
  src/
    App.css
    App.js
    App.test.js
    index.css
    index.js
    logo.svg

To see the application running open http://localhost:3000/. The page will reload if we make any edits in the app. Also, to run the tests just run command:

npm test

It will run the test watcher in an interactive mode.

react-blog-pic-2

At last to deploy the application, we can bundle it in production mode and optimize it for the best performance.

react-blog-pic-3

The build is minified and the filenames include the hashes. Finally, our app is ready to be deployed. Note that we have not described different components of the app yet. So, stay tuned !


KNOLDUS-advt-sticker

Written by 

Himanshu Gupta is a software architect having more than 9 years of experience. He is always keen to learn new technologies. He not only likes programming languages but Data Analytics too. He has sound knowledge of "Machine Learning" and "Pattern Recognition". He believes that best result comes when everyone works as a team. He likes listening to Coding ,music, watch movies, and read science fiction books in his free time.

1 thought on “Hello React #1: Creating a Single Page Application with React1 min read

Comments are closed.

Discover more from Knoldus Blogs

Subscribe now to keep reading and get access to the full archive.

Continue reading