Version Number
7.53.0
Codesandbox/Expo snack
https://codesandbox.io/p/devbox/interesting-spence-kgg47d
Steps to reproduce
Careful the link in codesandbox can crash your tab.
You have to open the dev console to see the infinite re-render
I think what I'm doing is "wrong" in the sense that it does not make sense (and I have now fixed my usage) but I don't understand what's happening and I think anyway there should be some protection against it.
It seems that
- if you initialize your
useForm with errors: {}
- monitor the errors state with
{formState: {errors}} = useFormContext()
You get an infinite re-render
export const FormAmountShowcase = () => {
const formProps = useForm<{ foo: string }>({
defaultValues: {foo: 'bar'},
errors: {},
})
return (
<FormProvider {...formProps}>
<FormComp/>
</FormProvider>
)
}
const FormComp = () => {
console.log('rendering')
const {formState: {errors}} = useFormContext<{ foo: string }>()
return <>Foo</>
}
Expected behaviour
no infinite re-render.
Either the input is accepted, or it should fail when this value is used.
What browsers are you seeing the problem on?
Chrome
Relevant log output
Code of Conduct
Version Number
7.53.0
Codesandbox/Expo snack
https://codesandbox.io/p/devbox/interesting-spence-kgg47d
Steps to reproduce
Careful the link in codesandbox can crash your tab.
You have to open the dev console to see the infinite re-render
I think what I'm doing is "wrong" in the sense that it does not make sense (and I have now fixed my usage) but I don't understand what's happening and I think anyway there should be some protection against it.
It seems that
useFormwitherrors: {}{formState: {errors}} = useFormContext()You get an infinite re-render
Expected behaviour
no infinite re-render.
Either the input is accepted, or it should fail when this value is used.
What browsers are you seeing the problem on?
Chrome
Relevant log output
Code of Conduct