Project Decription759270
Project Decription759270
we Can not says that react is Frame because react dosn't have components like
framework.
1.react dosn't have routing.
Q.1 Why we are not using or work on angular and veu framework .
or
Why react more popular than angular and veu frmework.
Ans-Because using of external library we can make react powefull like angular and
vew framework.react have alternatives.
//if you use angular you don't have any choise.if you gatting deficulty in any
function you don't have any alternative options.
//like angular and vue are bundeled we don't need every feature.if you download
like angular have many features but you only need 3 features so that makes your
website heavy and this increases the cost and size of project.
so that why we use ract for the our project . because react provide the facility if
to need that component than only you have to install.this make your project lite
size wise or cost wise.
-----------------------------------------------------------------------------
Q.2 why learn react not angular and vue?
because ract is more popular than anglar and vue (how to find using trands.google
website most searched) and you can learn angular also and vue .
in react opportunities are more.
-----------------------------------------------------------------------------
Q.3 using react what we build?
using react we make single page Application.and using react native we make mobile
application also.
-----------------------------------------------------------------------------
Q.4 what is single page Application
Normal website:-when we click any hyper link(like contact page) website sends
request to the server and server creates contact page and send to the browser and
browser engine(v8 engine) rander(means recreate hole page ) the page and show to
user.The problem is we need only contact component but server send and recreates
hole page.This is time taking process.
Single page:-when you click hyper link react already know what changes done by the
user in same page so react send request only for that componet to the server and
server send only that component only then browser does not rander hole page only
rander that component.
so conclusion
when server construct the hole page it will take to much time.like the hole page
size is 10kb so server sends 10kb file to browser.but in single page application
server sends that component that is need and size of that component is only 1kb and
in server side react is active to can not reload the page.
const(ES6)-it also used to make variable in ES6.once we declare the value connot
change.
-----------------------------------------------------------------------------
2.Arrow Function
normal function:- we use function key word to define function like
function sayName(name){
console.log(name);
}
sayName("ajeet");
Arrow Function:-function keyword not required and make function name as variable
and after put = sign and argument () => make one line function.
note:-if function have only one argument than only you remove () if 0 or more than
one arg than () compelsurry.
----------------------------------------------------------------------------
3.Import || Export(Module)
in ES6 we can make module.
Module:-means we can divide our code in different different files and parts then
all parts connect together and work.you can writen code in one file and if you need
code in other you import that module.
when you use module in your js you can add type module ot that page.
<script type="module" src="app.js"> without gives error.
{}-name which you import like here use hello(function name of sell file).
./-same file.
{data as da}-means use data name as ds
*you don't need to write again and again import for same file you can saprate
with ,.
#it creates object bundle and all export are in bunble object.
class Customer{
constructor(n){ //property
this.name=n;
}
age =25; //es7 property
buy(){ //method //make arrow also(es7)
console.log(this.name); //access name in this method
}
}
let list=["ayush","sharma","abhi"]
let newlist=[...list,"adarsh"];
let newlist=["adarsh",...list]
console.log(newlist);
function hello(...all){
console.log(all)
}
hello(1,2,3,4................n number of arg)
output
{1,2,3,4}
if i don't know how many argument pass than we use rest operator .here all is array
you can use like array.
----------------------------------------------------------------------------
Destructuring:- it is used to store array element in individual variable.
also used to store object property in individual varibale.
Array Destructuring:-
let arr=["ayush","sharma","abhi"];
let [stu1,stu2,stu3]=arr;
cosole.log(stu1)
output:ayush
//if you don't want to asign stu2 sharma and access in stu2 in abhi then
let[stu1, ,stu2]=arr;
object Destructuring:-
const person={
name:"vishwajeet",
age:28,
}
//console.log(person.age): //print person age
but i want to store in variable then
let {name,age}=person
console.log(name);
name me vlaue aa gya.
----------------------------------------------------------------------------
Reference(array,object) and primitive types(string,number)
primitive type:-
let a=10
let b=a;
//so here a value copy in b variable.here valiable point different memory and b
also.
let b=20;
//here no effect on a, a is 10
Reference type:-
let person={
name:"vishwa"
}
let person=person1;
//here person1 point person not copy person property into person 1.
Q.so how to copy person to person use spread operator(...) privious see.
let person1{
...person
}
person1.name="sharma"; only change occure in person1
----------------------------------------------------------------------------
Two most Important Array function MAP and FILTER
1.Map:-create new array and you can change the value of array also like.
let arr1=[1,3,4,5]
let arr2=arr1.map(function(x){//annonmous function
return x*2
});
console.log(arr2);
output
[1,9,16,25]
all the vlaue of arr1 pass one by one like loop in function(x) it retun arr2 this
is also a array.
React is all about components like any thing in we are makin using html is called
component like button,menue.Generly we are make full web page in html css but using
React we make different components and Creating a complete web page by combining
this components. not make every thing component only repeatable things like
button,manue only change the content.small components(button) use under any big
components.
"so in react we build component with html css and js.And then by combining these
components we built a page."
"so, components are reusable building block in user interface(html and css with js
make components)"
node.js-Earlier js is run on the browser but using node js we can run js in our
computer using browser v8 engine.
"Node.js is a js runtime built on chrome v8 js engine."it is also used for backend
development.
package-lock.json-node spcific.
node_module folder-install any package from npm stores in this folder.
public folder
favIcon-icon of website.
jsx=html+js
component folder--->file(subcomponent)
subcomponent-->export to app.js
app.js--->import subcomponent form
we pass only com
function app(){
return(
<div>
<subcomponent/>
</div>
)
}
export default app;
----------------------------------------------------------------
project name expence tracker
-----------------------------
props in react
propes-it is object .you pass data to a component.
app.js--->
function app(){
let expensetitle="school fees";
return(
<div>
<expenseitem title={expenseTitle}/>
</div>
)
const clickHandler=()=>{
alert("clicked");
}
even hendler-
<button onClick={clickHandler}></button>
yha pe hmane ek event ko handle kiya he like jb user click krega button pe to use
ek alert show hog .
step1-jaha pe event handle krna he event ka name like onClick ab ek function bana
he ki jb user click krga to wo function auto call ho jayega.jo apn ne upper bnaya
he clickHandler name ka.
state is hoock
like form me ham data fill krte he to me chata hu ki data fill krne ke bad data
clear bhi ho jaye ye kam hm state ki help se krnge.
useState("");
return-array
we use array distructuring
const [title, setTitle] =useState(props.title)