From 3045e90a800cc020b89ab41de7c6d9576a73b875 Mon Sep 17 00:00:00 2001 From: Alf Eaton <eaton.alf@gmail.com> Date: Tue, 4 Jul 2017 16:11:08 +0100 Subject: [PATCH] Simplify the onSubmit handler --- app/components/DeclarationQuestions.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/components/DeclarationQuestions.js b/app/components/DeclarationQuestions.js index c32e8e054f..1a3a7b0bac 100644 --- a/app/components/DeclarationQuestions.js +++ b/app/components/DeclarationQuestions.js @@ -36,12 +36,9 @@ class DeclarationQuestions extends React.Component { this.setState({ declarations }) } - changed = (declarations) => { + onChange = (declarations) => { this.setState({ declarations }) - } - - save = () => { - this.props.save(this.state.declarations) + // TODO: save changed declarations automatically? } autoresize = name => () => { @@ -54,15 +51,16 @@ class DeclarationQuestions extends React.Component { render () { const { declarations = {} } = this.state + const { save } = this.props // TODO: only display "submit" once declarations are complete return ( <div className="questions questions-reset content-metadata"> <FRC.Form - onSubmit={this.save} + onSubmit={save} validateOnSubmit={true} - onChange={this.changed} + onChange={this.onChange} layout="vertical"> <div className="question-section"> <div className="question-section-heading">PART I - Questions about ethics</div> -- GitLab