Replies: 1 comment
-
I dont think its possible. I have to write a new type along the lines of: type FormValues = {
foo: {
bar: {
value: number
}[]
}[]
} And write a function to convert to and from the UI type and the type expected by my API. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a basic form where the code for it is using
react-hook-form
and looks like:When there is an array with zero-values in it, the form displays the number of zeros in the array, fewer than it should. For instance, with an array of all zeros nothing gets shown:
Whereas an array with
[0, 1, 2]
:How can I fix this? One thing I noticed is that if I turned the numbers into strings, then zeros are rendered fine:
But as my form is being initialized from an API call, I would rather not have to find every number field and convert them to strings. Is there another way around this? I saw in this discussion, flat field arrays are not allowed, but I wasnt sure what was meant by a flat field array, I would guess that means arrays with false-y values in them? In my case, as I am using numbers I should never end up with an empty string, so is there a way for me to easily be able to convert the values to a string as the input is being rendered?
Thanks for any help.
codesandbox link
Beta Was this translation helpful? Give feedback.
All reactions