-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
39 lines (36 loc) · 769 Bytes
/
App.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
import React from 'react';
class App extends React.Component{
constructor(){
super(); //get context for ths
this.state = {
name: 'Arjun',
age : 0
}
}
update(e){
this.setState({name:e.target.value})
}
render(){
let name = this.props.name,
age = this.props.age
return (
<div>
<h1>Hello Application</h1>
<span>{name}:{age}</span><br/>
<span>{this.state.name}:{age}</span>
<div>
<input type="text" onChange={this.update.bind(this)}/>
</div>
</div>
)
}
}
App.propTypes = {
name: React.PropTypes.string.isRequired,
age: React.PropTypes.number.isRequired
}
App.defaultProps = {
name: 'Arjun',
age: 23
}
export default App