-
Codesandbox: https://codesandbox.io/s/rhf-use-field-array-twice-dqh44l In the code I am using useFieldArray twice: once to render read only view and once to render edit view where you can add new person by clicking the button. Problem: When I click Add person only the edit view updates. I have added console.log to display the contents and you can see that My understanding is that this is by design because useFieldArray only contains the id of the item and some kind of link to the actual list. Sorry I don't know the technical details but I am interested in how this works. Question: Is the correct way to implement this to use |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @tparvi 👋 |
Beta Was this translation helpful? Give feedback.
-
I have the same question as @BaileyMillerSSI. There are scenarios where you cannot pass it as prop. |
Beta Was this translation helpful? Give feedback.
Hi @tparvi 👋
I don't know the technical details of
useFieldArray
,but in this case, if you define fieldArray in your parent component and pass it as a prop to both
ReadOnlyList
andEditList
, it will work as expected.I hope someone else can clarify the technical details for you.
Please refer this sandbox