React Hook Form - useForm: setValue

preview_player
Показать описание
This session cover setValue API inside react hook form.

Рекомендации по теме
Комментарии
Автор

Thanks so much Bill. This video solved my issue with a more complex component wrapped in a Controller and passing the value through to ZodResolver as a Number instead of String. Was tearing my hair out before finding this!

djb
Автор

do you have an exemple of autocomplete with chakra-ui? thanks

brahimo
Автор

How to trigger onChange while setValue in react-native . ? For example a user enter age 18 or more will show another field by rerender, i wrote a code on "Onchange" and check the values to show another field, but setState will not trigger onChange

arjunramdas
Автор

I could make the setValue works with an onChange inside the register method, and the input is correct visually with the new setValue, however, when I submit the data seems one state before my onChange setValue function.

Im trying to understand but cant find the reason.

also tried the setValueAs: v => {...}, the value on the v argument is correct when I do a console.log, but when I return v and also do a submit, the data again seems one state before my onChange

any reasons? thanks

JavaxTv
Автор

How to update only two fields value from 20 fields ....please give me the solution

WweRoman
Автор

@Beier Luo Awesome video. Question should we only use SetValue with uncontrolled components? For example i'm working on a custom Radio Button in react native and the only solution i can think of updating the value and validation is with SetValue. Is this the right approach or is there a better approach?

emekaitegbe
Автор

I have a quantity field and price field how to multiply them in a total field? Thanks

harrisonwell
Автор

I’m still wrapping my head around all of the React-Hook-form APIs.
I am wanting to use setValue inside of the callback function that you pass to handleSubmit in order to set all of the values back to their default values after I submit the form. Is that the right way to approach uncontrolled inputs? I’m wanting to avoid using useState to limit re-renders.

CalebStephensPlaysPiano
Автор

thanks for vid. what about setValue for native checkbox? should it be boolean or a string?

OldestJunior
Автор

Thanks, it's very helpful.
Is there any other way to setValues with multiple objects?
Like you did within defaultValues(yourDetails).

neeraj_by
Автор

Thanks for the great info. When I try using formContext.setValue('myfield'), I get: "Cannot update a component ("SelectInput") while rendering a different component ("MyInput"). Wondering if you have some general tips for how to resolve that? I'm using the React-Admin framework. Not sure yet if it's an issue in the framework or my own code.

scruffythebug
Автор

Hi! I found this very helpful! But I have a problem here, setValue does not work currently.

leekimah
Автор

How to set value for select drop-down values

gurureddy
Автор

If I want to show an error for being a "required field" yourDetails.firstName . How can I indicate it?

ItzelRDiaz