class CategoryRequest extends React.Component {
constructor(props) {
super(props);
+ this.category = React.createRef();
+
+ this.handle_submit = this.handle_submit.bind(this);
+ }
+
+ handle_submit(event) {
+ const category_input = this.category.current;
+ const category = category_input.value;
+
+ /* Prevent the default page-changing form-submission behavior. */
+ event.preventDefault();
+
+ console.log("Do something here with category: " + category);
}
render() {
include the number of items for each person to submit.
</p>
- <form>
+ <form onSubmit={this.handle_submit} >
<div className="form-field large">
<input
type="text"
placeholder="6 things at the beach"
required pattern=".*[0-9]+.*"
title="Category must contain a number"
- >
- </input>
+ ref={this.category}
+ />
</div>
<div className="form-field large">