useForm defaultvalues
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
useForm
Performant, flexible and extensible forms with easy-to-use validation.
4 Replies
noble-gold•2y ago
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)
optimistic-goldOP•2y ago
@liorpr payload from the config api is just too big.. so cant really wait that long
its bad for ux
rare-sapphire•2y ago
The reactive values api is literally the next point in the docs: https://www.react-hook-form.com/api/useform/#values
useForm
Performant, flexible and extensible forms with easy-to-use validation.
optimistic-goldOP•2y ago
@TkDodo 🔮 now im feeling dumb
you learn something new everyday