forked from AdaGold/madlib
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathMadlibForm.js
61 lines (51 loc) · 1.21 KB
/
MadlibForm.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, { Component } from 'react';
import './MadlibForm.css';
import PropTypes from 'prop-types'
class MadlibForm extends Component {
constructor() {
super();
}
static propTypes = {
// addStudent: PropTypes.func.isRequired,
}
wordValid = () => {
return this.state.email.match(/\S+@\S+/)
}
// clearForm = () => {
//
// }
onSubmit = (event) => {
event.preventDefault();
this.props.renderStory()
// this.clearForm();
}
render() {
const inputs = this.props.words.map (item => {
return <div key={ item.key }>
<label htmlFor={item.key}>
{item.label}:
</label>
<input
name={item.label}
// placeholder={item.label}
onChange={(event) =>
{ this.props.updateWord(item.key, event.target.value) }}
/>
</div>
});
return (
<div>
<form onSubmit={this.onSubmit}
className="new-madlib-form">
{inputs}
<input
className="button success"
type="submit"
value="Submit"
/>
</form>
</div>
);
}
}
export default MadlibForm;