-
Notifications
You must be signed in to change notification settings - Fork 18
remove ref from for get the data in TargetContainer #2625
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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(); | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same question for the native apps implementation as for the web client. Can you give me an example implementation I can use everywhere for the native apps? What is the difference of this patch against treecounter-app/app/components/Authentication/SignUp/SignUp.native.js Lines 44 to 50 in 4ab1b4d
treecounter-app/app/components/Authentication/SignUp/SignUp.native.js Lines 84 to 91 in 4ab1b4d
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are using TCombForm therefor it will only allow to access the method using ref. if we need to optimise this then we need to change TCombForm to Formik form that we are using in tree registration There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The refactoring work to change all remaining old Tcomb forms to Formik is also still open in #2475 :-) |
||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
shouldComponentUpdate(nextProps) { | ||||||||||||||||||||||||||||||||
|
@@ -37,14 +38,14 @@ export default class Target extends Component { | |||||||||||||||||||||||||||||||
style={{ flex: 1, marginTop: Platform.OS === 'ios' ? 140 : 100 }} | ||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||
<Form | ||||||||||||||||||||||||||||||||
ref={'setTargetForm'} | ||||||||||||||||||||||||||||||||
ref={this.formRef} | ||||||||||||||||||||||||||||||||
type={targetFormSchema} | ||||||||||||||||||||||||||||||||
options={this.props.schemaOptions} | ||||||||||||||||||||||||||||||||
value={this.props.treecounter} | ||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||
</CardLayout> | ||||||||||||||||||||||||||||||||
<PrimaryButton | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw. this is one example of a form where the ActivityIndicator within the PrimaryButton is not yet integrated (compare #1837), so the user does not know if the API requests for updating his target is still working or the app is crashed ;-) |
||||||||||||||||||||||||||||||||
onClick={this.props.onSubmitTarget} | ||||||||||||||||||||||||||||||||
onClick={()=>this.props.onSubmitTarget(this.formRef.current)} | ||||||||||||||||||||||||||||||||
buttonStyle={{ marginTop: 10 }} | ||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||
{this.state.label} | ||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I am looking for a universal solution we can use throughout our whole codebase I would like to ask what is the difference of this solution vs.
treecounter-app/app/components/Authentication/SignUp/SignUp.js
Lines 145 to 165 in 4ab1b4d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in container file we are using ref to access the tcombform ref.
I just remove that ref and added tcombform ref in callBack function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then I assume this patch should be the template for doing it everywhere else now.