append on useFieldArray #8485
-
I would like to create an array of inputs with at least 1 input by default. while submitting the form inputs should not be empty. i've created this, and it works great but for some reason, append will not let me add/append new inputs while the previous one is empty. any idea of how to workaround this issue? am i approaching this thing incorrectly? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
When using "append" function to append new value on field array, there is a "compact" step to filter "undefined" or "null" when merging new value to current field array value and the empty space is also excluded as "compact" is using "Array.filter(Boolean)". You can update append default value to blank space " " instead of empty space to make it work as your expectation. Working demo: https://codesandbox.io/s/romantic-phoebe-4knms2?file=/src/App.js |
Beta Was this translation helpful? Give feedback.
@vnevermore :
When using "append" function to append new value on field array, there is a "compact" step to filter "undefined" or "null" when merging new value to current field array value and the empty space is also excluded as "compact" is using "Array.filter(Boolean)".
You can update append default value to blank space " " instead of empty space to make it work as your expectation.
Working demo: https://codesandbox.io/s/romantic-phoebe-4knms2?file=/src/App.js