-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiview.html
More file actions
95 lines (70 loc) · 1.51 KB
/
Copy pathmultiview.html
File metadata and controls
95 lines (70 loc) · 1.51 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html>
<head>
<title>First React Program </title>
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
</head>
<body>
<script type="text/babel">
class Maindata extends React.Component{
constructor(props) {
super(props);
this.state = {name: ""};
}
change(v){
console.log(v.target.value);
this.setState({
name: v.target.value
});
}
render() {
return (
<div>
<Child2 name={this.change.bind(this)}/>
<Child1 name2={this.state.name}/>
</div>
);
}
}
class Child1 extends React.Component{
constructor(props) {
super(props);
}
componentDidMont(){
console.log("mount");
}
render() {
return (
<div>
<h1>{this.props.name2}</h1>
</div>
);
}
}
class Child2 extends React.Component{
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
}
handleChange(v) {
this.props.name(v);
console.log("working");
}
render() {
return (
<div>
<input type="text" id="t1" onChange={this.handleChange}/>
</div>
);
}
}
ReactDOM.render(
<Maindata/>,
document.getElementById('root')
);
</script>
<div id="root"></div>
</body>
</html>