-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddUser.jsx
More file actions
44 lines (37 loc) · 979 Bytes
/
AddUser.jsx
File metadata and controls
44 lines (37 loc) · 979 Bytes
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
'use strict';
import React, {Component} from 'react';
import PropTypes from "prop-types";
export default class AddUser extends Component{
static get propTypes(){
return{
addUser : PropTypes.func
}
}
constructor(props){
super(props);
}
onNameChange(e){
e.preventDefault();
e.stopPropagation();
this.name = e.target.value;
}
onSubmit(event) {
event.preventDefault();
event.stopPropagation();
if (this.name) {
this.props.addUser({name: this.name});
this.name = '';
}
}
render() {
return(
<div>
<form onSubmit={event => this.onSubmit(event)}>
<label>Name : </label>
<input type="text" onChange={event => this.onNameChange(event)}/>
<button type="submit">Add</button>
</form>
</div>
);
}
}