-
-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
values prop not honored by useForm #1780
Comments
Also, I've tried the following alternative for populating
Log shows the |
Further, if I try to use setDefaults, like:
then it results in |
This issue isn’t specific to Inertia; it’s a characteristic of React’s If you want to do so, you need to write a useEffect(() => {
setData(values)
}, [values]) However, here you need to use useEffect(() => {
setData(values)
}, [JSON.stringify(values)]) Another possible solution is to create a key based on the <GenericForm key={JSON.stringify(currentValues)} fields={formFields} values={currentValues}/> |
I'm using a generic component for Create/Update forms. The difference between the two is
values
parameter passed to Update form.Now, this is called in the following manner for the two purposes:
Create Form
Update Form
However, when the form is rendered, the
data
always contains thedefaultValues
and never thevalues
. While this is OK for Create Form, it means losing the existing value for Update Form.The text was updated successfully, but these errors were encountered: