Skip to content

Instantly share code, notes, and snippets.

@awareness481
Last active May 1, 2018 16:30
Show Gist options
  • Save awareness481/fee616472c7e973b01993aa80c934797 to your computer and use it in GitHub Desktop.
Save awareness481/fee616472c7e973b01993aa80c934797 to your computer and use it in GitHub Desktop.
import React from 'react';
export default class Action extends React.Component {
constructor(props) {
super(props);
this.state = {
val: ''
}
this.handleAction = this.handleAction.bind(this);
this.handleChange = this.handleChange.bind(this);
}
handleAction (e) {
e.preventDefault();
return e.target.query.value;
}
handleChange(e) {
this.setState({ val: e.target.query.value});
}
render() {
return (
<div>
<form onSubmit={this.handleAction}>
<input type='text' name='query' value={this.state.val} onChange={this.handleChange}/>
</form>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment