-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWelcome.js
40 lines (31 loc) · 808 Bytes
/
Welcome.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
import React, { Component } from 'react'
class Welcome extends Component {
constructor(){
super();
this.state = {value: ''};
// this.onChange = this.onChange.bind(this)
}
onChange = (e) => {
const re = /^[0-9\b]+$/;
if (e.target.value === '' || re.test(e.target.value)) {
this.setState({value: e.target.value})
}
}
render() {
return (
<div>
<input value={this.state.value} onChange={this.onChange}/>
</div>
)
}
}
export default Welcome
//import React, { Component } from 'react'
//
//class Welcome extends Component {
// render () {
// return <h1>Welcome {this.props.name} a.k.a {this.props.heroName} </h1>
// }
//}
//
//export default Welcome