From 778697abf13e6d1aa548bfabaa7b5498de16ca4d Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Thu, 18 Apr 2019 17:37:07 +0100 Subject: [PATCH] Use input element's value directly Since we're keeping the input as a ref anyway, let's use that rather than requiring the value to be passed to `validate`. This allows others to call `validate` as well. --- src/components/views/elements/Field.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/views/elements/Field.js b/src/components/views/elements/Field.js index 93d1f1e71d..dfe3a51697 100644 --- a/src/components/views/elements/Field.js +++ b/src/components/views/elements/Field.js @@ -55,7 +55,6 @@ export default class Field extends React.PureComponent { onFocus = (ev) => { this.validate({ - value: ev.target.value, focused: true, }); // Parent component may have supplied its own `onFocus` as well @@ -66,7 +65,6 @@ export default class Field extends React.PureComponent { onChange = (ev) => { this.validate({ - value: ev.target.value, focused: true, }); // Parent component may have supplied its own `onChange` as well @@ -77,7 +75,6 @@ export default class Field extends React.PureComponent { onBlur = (ev) => { this.validate({ - value: ev.target.value, focused: false, }); // Parent component may have supplied its own `onBlur` as well @@ -90,10 +87,11 @@ export default class Field extends React.PureComponent { this.input.focus(); } - validate({ value, focused }) { + validate({ focused }) { if (!this.props.onValidate) { return; } + const { value } = this.input; const { valid, feedback } = this.props.onValidate({ value, focused,