We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug
Using a nested JSON object in initialValues causes infinite re-renders. Also, form fields can't be changed.
Steps-
Example -
const Test = () => { const { form, handleSubmit, values, pristine, submitting } = useForm({ onSubmit, validate, initialValues: { name: { firstName: 'Clark', lastName: 'Kent', } } });
Form should render once with initial values. And we should be able to update form field values.
https://codesandbox.io/s/cold-https-6v26o
node: v10.2.1 react-final-form-hooks: "2.0.0", Mac OS Mojave 10.14.2
Screenshot
The text was updated successfully, but these errors were encountered:
I think that we could initialize value after react rendering, that means should set initial value on useEffect, in this case, a temporary solution is:
useEffect
useEffect(() => { form.initialize({ name: { firstName: 'Clark', lastName: 'Kent', } }); }, []);
Sorry, something went wrong.
Thanks @l1nyanm1ng
For future visitors to this issue, you can also use useMemo to make sure the object reference stays the same
useMemo
const initialValues = useMemo(() => ({ name: { firstName: 'Clark', lastName: 'Kent', } }), []) const Test = () => { const { form, handleSubmit, values, pristine, submitting } = useForm({ initialValues }); }
Thanks @Jephuff for the work around.
No branches or pull requests
Are you submitting a bug report or a feature request?
Bug
What is the current behavior?
Using a nested JSON object in initialValues causes infinite re-renders.
Also, form fields can't be changed.
Steps-
Example -
What is the expected behavior?
Form should render once with initial values.
And we should be able to update form field values.
Sandbox Link
https://codesandbox.io/s/cold-https-6v26o
What's your environment?
node: v10.2.1
react-final-form-hooks: "2.0.0",
Mac OS Mojave 10.14.2
Other information
Screenshot
The text was updated successfully, but these errors were encountered: