Get Started with ReactJs
Below given steps will guide you through setting up to create your first React Project so follow along :
#step 1
npm install -g create-react-app
create-react-app my-app
cd my-app
npm start
Let’s discuss above commands :
The first command will install React-cli globally to your computer so it can be easily accessed through terminal to quickly create projects.
Second command “create-react-app my-app” will create a new folder named my-app in the directory where you run the command and setup everything you needed for the project there.
Get Sarabjeet Singh’s stories in your inbox
Join Medium for free to get updates from this writer.
Let’s move to step 2 which is to create our first component.
# Step 2
We will go ahead and create our first component using jsx syntax. React need to be kept in scope to use Jsx otherwise it will throw an error while compiling.
import React from ‘react’;
const Greeting = function() {
return(
<h2>Hello Guest!</h2>
)
}
export default Greeting;
So here we simply create a component name Greeting which will return a heading element with text “Hello Guest!” and to add this into your pre generated code with the CLI. Just import the file into app.js with
“import Greeting from ‘./greeting’”
and in the render method of the class just add
“<Greeting />”
It will re render the DOM and display the heading element.






