fix indent and put submit on enter

This commit is contained in:
Jonathan Rainville 2018-08-15 13:00:46 -04:00 committed by Iuri Matias
parent 29a0d5c658
commit c8504b0024

View File

@ -19,6 +19,14 @@ class Blockchain extends React.Component {
this.setState({ valueSet: e.target.value });
}
checkEnter(e, func) {
if (e.key !== 'Enter') {
return;
}
e.preventDefault();
func.apply(this, [e]);
}
setValue(e) {
e.preventDefault();
@ -56,14 +64,15 @@ class Blockchain extends React.Component {
render() {
return (<React.Fragment>
<h3> 1. Set the value in the blockchain</h3>
<Form inline>
<Form inline onKeyDown={(e) => this.checkEnter(e, this.setValue)}>
<FormGroup>
<FormControl
type="text"
defaultValue={this.state.valueSet}
onChange={(e) => this.handleChange(e)}/>
<Button bsStyle="primary" onClick={(e) => this.setValue(e)}>Set Value</Button>
<HelpBlock>Once you set the value, the transaction will need to be mined and then the value will be updated on the blockchain.</HelpBlock>
<HelpBlock>Once you set the value, the transaction will need to be mined and then the value will be updated
on the blockchain.</HelpBlock>
</FormGroup>
</Form>