-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-form.html
49 lines (43 loc) · 1.46 KB
/
index-form.html
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
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<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>
<title>Document</title>
</head>
<body>
<div id="app"></div>
<script type="text/babel">
class App extends React.Component{
state={
name:'Ruchika',
age: 20
}
handleChange=(e)=>{
this.setState({
name:e.target.value
});
}
handleSubmit=(e)=>{
e.preventDefault();
console.log('form has submitted', this.state.name);
}
render(){
return(
<div className="app-content">
<h1>My name is {this.state.name}</h1>
<form onSubmit={this.handleSubmit}>
<input type="text" onChange={this.handleChange}/>
<button>Submit</button>
</form>
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById('app'));
</script>
</body>
</html>