#useForm defaultvalues

6 messages · Page 1 of 1 (latest)

gray sandal
#

So useFrom provides a way to populate the form with default values the problem is that when we use usequery it does not returns a promise so we cant really await that and i tried to wrap in new promise constructor that does not work either.. so how can i await the react query inside a function so when the data is available i will be able to populate the form

https://www.react-hook-form.com/api/useform/#defaultValues

Performant, flexible and extensible forms with easy-to-use validation.

orchid knot
#

show a spinner while the query is pending and show a form wrapper when the query is ready,
then inside the form wrapper you can "useForm" with the default values, (and you know the data is ready too)

gray sandal
#

@orchid knot payload from the config api is just too big.. so cant really wait that long

#

its bad for ux

wanton obsidian
gray sandal
#

@wanton obsidian now im feeling dumb