-
Notifications
You must be signed in to change notification settings - Fork 0
/
reactTut13.js
71 lines (59 loc) · 1.91 KB
/
reactTut13.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Component Mounting Process
import React,{Component} from "react";
import ReactDOM from "react-dom";
import CousinsB from "./CousinsB";
// Sabse pehle constructor call hua hai uske baad getDerivedStateFromProps call hoga uske baad render function call hoga uske baad componentDidMount call hoga
// Sabse pehle child ke saare function call hoge uske baad componentDidMount call hoga parent ka
class Cousins extends Component{
constructor(props){
super(props);
this.state={
count:0,
// names:['Madhav','Manav','Shubham','Chinu']
}
console.log("Cousins Constructor is called");
}
// It creates a virtual DOM which is created after the entire code is run
componentDidMount(){
console.log("Cousins componentDidMount called")
}
static getDerivedStateFromProps(props,state){
console.log("Cousins getDerivedStateFromProps Calling")
return null;
}
render(){
console.log("Cousins render function called!");
return <div>
<h1>This is the list of my cousins</h1>
<h1>Value of count is: {this.state.count}</h1>
<CousinsB/>
</div>
}
}
ReactDOM.render(<Cousins/>,document.getElementById('root'));
// CousinsB
// import React,{Component} from "react";
// import ReactDOM from "react-dom";
// class CousinsB extends Component{
// constructor(props){
// super(props);
// this.state={
// name:"Lakshay",
// }
// console.log('CousinsB constructor called');
// }
// componentDidMount(){
// console.log("CousinsB componentDidMount called!");
// }
// static getDerivedStateFromProps(props,state){
// console.log("CousinsB getDerivedStateFromProps called");
// return null;
// }
// render(){
// return<div>
// <h1>This is CousinsB</h1>
// </div>
// }
// }
// ReactDOM.render(<CousinsB/>,document.getElementById('root'));
// export default CousinsB;