forked from tutsplus/ReactFormApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
60 lines (46 loc) · 1.39 KB
/
app.js
File metadata and controls
60 lines (46 loc) · 1.39 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
import React from 'react'
import { render } from 'react-dom'
var App = React.createClass({
render:function(){
return(
<div>
TutsPlus - Welcome to React Form App
</div>
);
}
});
var FormComp = React.createClass({
getInitialState: function () {
return {lName: '',fName:'',Name:''};
},
handleFNameChange:function(event){
this.setState({fName: event.target.value});
},
handleLNameChange:function(event){
this.setState({lName: event.target.value});
},
handleClick:function(){
var fullName = this.state.fName + ' ' + this.state.lName;
this.setState({Name:fullName});
},
render:function(){
return(
<div>
<h2>TutsPlus - React Form Tutorial</h2>
<hr />
<label>First Name: </label>
<input type="text" value = {this.state.fName} onChange={this.handleFNameChange} />
<br />
<label>Last Name: </label>
<input type="text" value = {this.state.lName} onChange={this.handleLNameChange} />
<br />
<input type="button" onClick={this.handleClick} value="Submit" />
<hr />
<h3>Your full name is </h3> {this.state.Name}
</div>
);
}
})
render((
<FormComp />
),document.getElementById('app'))