# How to handle fields dependencies in Formik

**URL:** <https://forum.codewithmosh.com/t/how-to-handle-fields-dependencies-in-formik/16400>\
**Category:** React Native\
**Created:** [November 10, 2022, 7:02pm UTC](https://forum.codewithmosh.com/t/how-to-handle-fields-dependencies-in-formik/16400 "2022-11-10T19:02:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmerli](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@cmerli](https://forum.codewithmosh.com/u/cmerli)\
**Post date:** [November 10, 2022, 7:02pm UTC](https://forum.codewithmosh.com/t/how-to-handle-fields-dependencies-in-formik/16400/1 "2022-11-10T19:02:29Z")

</div>

Hello,  
I followed the example in the video #9 under the Forms Lecture of the React Native course:

> **[9- Building the Form Component](https://codewithmosh.com/courses/887220/lectures/16762474)**
>
> Master the Fundamentals of Building Native Mobile Apps with React Native and Expo

After extracting the Form component I have a structure like this:

```auto
<Form
	initialValues={{
	  fieldA: "",
	  fieldB: "",
	}}
	onSubmit={handleSubmit}
	validationSchema={validationSchema}>
	<FormTextInput
		name="fieldA"
		placeholder="Field A"
		required
	/>
	<FormTextInput
		name="fieldB"
		placeholder="Field B"
		required
	/>
	<SubmitButton>Send</SubmitButton>
</Form>

```

In a scenario like this, I would like the text in `fieldB` to be cleared when the text in `fieldA` is cleared manually.  
In this set up I don’t have access to formik methods like `setFieldValue` etc.

How can I detect one field changing (ok i could create an `onChange` event), and especially how do I edit the value of another field?

---

<div class="post-metadata">

**Author:** ![delboy1978uk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/delboy1978uk/32/4513_2.png) [@delboy1978uk](https://forum.codewithmosh.com/u/delboy1978uk)\
**Post date:** [November 16, 2022, 5:20pm UTC](https://forum.codewithmosh.com/t/how-to-handle-fields-dependencies-in-formik/16400/2 "2022-11-16T17:20:22Z")

</div>

Just use `onChange(yourHandlerFunction)` on your input! Check docs here

> **[| Formik](https://formik.org/docs/api/formik#example)**
