From 6b3af40b36202e56279bfa29017058fbc49bc1d4 Mon Sep 17 00:00:00 2001 From: sanjay radadiya Date: Mon, 17 Aug 2020 14:19:21 +0530 Subject: [PATCH] remove ref from for get the data in TargetContainer --- app/components/Target/index.js | 5 +++-- app/components/Target/index.native.js | 5 +++-- app/containers/TargetContainer/index.js | 13 +++---------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/app/components/Target/index.js b/app/components/Target/index.js index 9506cd144..6f2a1a23d 100644 --- a/app/components/Target/index.js +++ b/app/components/Target/index.js @@ -41,6 +41,7 @@ export default class Target extends Component { label: countTarget !== 0 ? i18n.t('label.update') : i18n.t('label.save'), initialValues: { countTarget, targetYear, targetComment } }; + this.formRef=React.createRef(); } shouldComponentUpdate(nextProps) { return JSON.stringify(nextProps) !== JSON.stringify(this.props); @@ -52,12 +53,12 @@ export default class Target extends Component { {i18n.t('label.set_target')} - + this.props.onSubmitTarget(this.formRef.current)}> {this.state.label} diff --git a/app/components/Target/index.native.js b/app/components/Target/index.native.js index b60a47238..869b9a300 100644 --- a/app/components/Target/index.native.js +++ b/app/components/Target/index.native.js @@ -20,6 +20,7 @@ export default class Target extends Component { this.state = { label: countTarget !== 0 ? i18n.t('label.update') : i18n.t('label.save') }; + this.formRef=React.createRef(); } shouldComponentUpdate(nextProps) { @@ -37,14 +38,14 @@ export default class Target extends Component { style={{ flex: 1, marginTop: Platform.OS === 'ios' ? 140 : 100 }} >
this.props.onSubmitTarget(this.formRef.current)} buttonStyle={{ marginTop: 10 }} > {this.state.label} diff --git a/app/containers/TargetContainer/index.js b/app/containers/TargetContainer/index.js index 412c868f2..485b93f8f 100644 --- a/app/containers/TargetContainer/index.js +++ b/app/containers/TargetContainer/index.js @@ -17,14 +17,8 @@ class TargetContainer extends React.Component { }; this.onSubmitTarget = this.onSubmitTarget.bind(this); } - onSubmitTarget = () => { - /* debug( - '\x1b[45m targetCOntainer', - this.refs.targetContainer.refs.setTargetForm.validate - ); */ - //debug('\x1b[0m'); - //debug(this.refs.targetContainer.refs.setTargetForm.validate()); - let value = this.refs.targetContainer.refs.setTargetForm.getValue(); + onSubmitTarget = (formRef) => { + let value = formRef.getValue(); if (value) { this.props .SubmitTarget(value, this.props.navigation) @@ -41,7 +35,7 @@ class TargetContainer extends React.Component { } }, () => { - this.refs.targetContainer.refs.setTargetForm.validate(); + formRef.validate(); } ); }); @@ -51,7 +45,6 @@ class TargetContainer extends React.Component { render() { return (