TanStackT
TanStack9mo ago
10 replies
awake-maroon

How to reset the value of an object field in an array

hi everyone. is there a way to reset manually a value in an array field?
<td>
  <form.Field
    name={`lines[${i}].building_product_group`}
  >
    {(subfield) => (
      <Select
        ...
        onChange={(e) => {
          subfield().handleChange(
            e.currentTarget.value,
          );
          // <--- How can i reset building_product_type ?
        }}
      />
    )}
  </form.Field>
</td>
<td>
  <form.Field
    name={`lines[${i}].building_product_type`}
  >
    {(subfield) => (
      <Select
        options={
          // <--- options depends on building_product_group
        }
        ...
      />
    )}
  </form.Field>
</td>
Was this page helpful?