You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
Because TypedController is always "different" component, React remounts the component endlessly with the following warning:
Warning: Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.
in TextInput (at App.tsx:23)
in Controller
in Unknown (at App.tsx:20)
in div (at App.tsx:18)
in App (at src/index.tsx:7)
Thanks.
The text was updated successfully, but these errors were encountered:
Hi,
useTypedController
only recreatesTypedController
component whencontrol
is changed:strictly-typed/src/useTypedController.tsx
Line 32 in 3d02e7b
But actually
useForm
returns differentcontrol
object on every render, andTypedController
is always recreated.https://github.com/react-hook-form/react-hook-form/blob/e757653b39645bf9f547525d27f88224d8049539/src/useForm.ts#L1162
This causes the input component to be unmounted and remounted repeatedly, and can impact on both performance and experience.
We are encountering the worst case of it, where the input component triggers rerender of the parent on its initial render using
useEffect
:Because
TypedController
is always "different" component, React remounts the component endlessly with the following warning:Thanks.
The text was updated successfully, but these errors were encountered: