Field array - conditional rendering #2593
-
I have a form where you can add/remove items, and where each item has a However, when using How should I proceed to conditionnally display elements in a fieldArray row? Here's a simplified example: https://codesandbox.io/s/react-hook-form-usefieldarray-forked-61zqg?file=/src/index.js When you change the type from |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
I think there is an inherente problem with rhf and dynamically drawing / removing inputs but I feel like rhf would profit from some "forceRerender" function or the like I was reading through the docs, but it wasn't clear to me how to force a rerender or what the implications of a rerender are (as it isn't controlled, I guess all the values are lost?) |
Beta Was this translation helpful? Give feedback.
-
For others who encounter the same issue, here is the solution:
we do have a plan to make it work with conditional re-render for |
Beta Was this translation helpful? Give feedback.
For others who encounter the same issue, here is the solution:
watch
can watch the entire FieldArray, which similar behavior as Controlled formuseWatch
we do have a plan to make it work with conditional re-render for
useFieldArray
, but there are other priorities for now.