React Introduction
React Introduction
Every react app has at least one component which would we refer to the app component.
React Js
This app component represents a react app and all the other components are placed inside it.
This results in a true like content hierarchy.
react is a library which means it has a very specific purpose and that is to define user
interfaces also called as views and this is where it gets more amazing.
It just takes care of the view and rest everything is left for you to decide.
You can plan the architecture decide which libraries to use for what functionalities exec
tracks etc.
You can even add react in parts of your existing web application because it's just for you
on a doesn’t disturbs existing technology stack and this is one of the biggest difference
between angular and react
angular is a framework and it comes with out-of-the-box solutions for routing handling
network request etc So you don't have control at the that level.
React Js
Search create react app in chrome ahe install as per github intsructions provided
So in this case you will be using create react app only once to create our project and we
would notneed to run it afterwards.
So that's why we're using npX over here.
So first let's install node Js so then simply download and install
Cmd=>
React Js
node -v
So this gives the version of node installed installing the system so this just confirms
whether node install started properly or not.
npm -v
So this returns the version of npm install along with node.
So again this verifies whether npm was installed on the system or not.
So as you can see I'm getting versions
That means it's installed properly on my system.
npx
So do running.
First we need to go to the project directly.
So CDE followed by whatever was your project name.
React Js
Where ever you got this file package.json then run command
>npm start
So what does command does is
it starts a local server unloads the default apllication created by create react app
in the browser.
So if I go back to the Chrome on as you can see create react app created this default application
for us
So this is the project structure created by create react app for our ReACT application.
Let's talk about this first directory node modules so it contains all the dependencies or packages
which
are installed by create react app the build and run your react application.
React Js
Then we've got this public folder in here you've got the index html file.
React Js
So this is the html file which is used in single page applications to load all the remaining content
dynamically.
Then you've got this package-lock.json files that contains the details of all the different
dependensies installed along with their specific versions.
Similarly you've got another file package.json that contain some more details about your
application. So the name of the application , version the in dependencies with minimum versions
some scripts browserless.
so which browsers to support in production which browsers to support in development et c et c.
<div id="root"></div>
So index.js file it mounts an entire application inside that root div or the div with id root.
it is using this library ReactDom this reactdom library is used to manipulate the
browser dom
so this line is it's mounting are application component in the
division with Id root