Module 1 - Introduction to React JS
Module 1 - Introduction to React JS
Author
Srinivas Dande
3) Both npm folder and E:\NodeJS-14 folder will be set to path automatically by the
Installers.
4) If any problem for your path then you can set path to npm folder and E:\NodeJS-14
folder as follows.
At Command Line:
set path = %path%;E:\NodeJS-14;
At Command Line:
set path = %path%;C:\Users\SRINIVAS\AppData\Roaming\npm;
D:\ReactJS\MyLabs> cd lab1
A. package.json =>
All the dependencies required for React project
NPM download all dependencies based on this file only.
B. index.html=>
Starting Point of the Application while rendering.
C. index.css =>
global styles goes here
D. index.js =>
Backing the index.html
1. index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Best React Training</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="myroot">
</div>
</body>
</html>
2. index.js
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
4. App.js
import React from 'react';
import './App.css';
return (
<div className="myclass">
<p className="myclass1"> Welcome to {companyName}</p>
<p className="myclass2"> You are learning {courseName} from Srinivas Dande</p>
</div>
);
}
5. App.css
.myclass1{
font-size: 25px;
color:red;
text-align: center;
font-family: Cambria;
}
.myclass2{
font-size: 20px;
color:blue;
text-align: center;
font-family: Cambria;
}
.myclass {
border: 2px solid red;
border-radius: 5px;
}
4) Render function includes the <App/> component under <div> whose root is myroot.
5) Finally index.html will be displayed.
Questions:
Q1) How to install the React?
Ans:
npm install -g create-react-app
Q11)What is npm?
Ans:
Npm - Node Package Manager
npm is part of NodeJS.
npm is reponsible to download and manage the packages required for your project
npm version : 6.14.6
Note : Above UnInstallation Process has to clean both npm and npm-cache folders
if not happened then remove manually.