Getting started with ReactJS
The very first question comes into the mind of the beginners is what is ReactJS ?
According to Wikipedia : React is a JavaScript library for building user interfaces. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications, as it is optimal for fetching rapidly changing data that needs to be recorded.
Now the question which comes is what we can actually build with ReactJS ?
Using react we can build
- Web Applications
- Mobile Applications (React Native)
- Single Page Applications (SPA)
- Progressive Web Apps (PWA)
So how do we get started with ReactJs ?
Requirements
Getting Started
- First open your terminal and type
npm install -g create-react-app
this will install react globally in your machine
2. After that go to the folder where you want to create your first react app and open terminal there (here in my case i am using git bash) and type
npx create-react-app my-first-react-app
Note :
- my-first-react-app is the name of your react app.
- If you get any error while creating your app delete your npm cache using
npm cache clean --force
3. Now enter into your app folder by typing
cd my-first-react-app
your app folder structure will look like this
4. Then run your app by typing
npm start
and then visit http://localhost:3000/ in your preferred browser. You will see that your app is running in the browser.
5. Now it’s time to edit our app. Open your project folder in your preferred code editor (I’ll recommend you to use vsCode editor but it’s all upon you) and then go to the src folder and open app.js . Remove <header></header> tag code and type Hello World inside h1 tag.
6. Now refresh your browser and see the changes.
7. Yo 😎 you have created your first react app. Now it’s time to deploy your app by typing in your terminal
npm run build
8. This will create a build folder inside your app project folder.
9. The build folder contains html, css and js files which are now ready to deploy in your preferred server.
That’s it folks we have created our first React app. Here is the GIT repository for that.