refine
refine copied to clipboard
[BUG] useForm from @refinedev/react-hook-form race condition for setting values from query result
Describe the bug
The useEffect in the useForm hook from @refinedev/react-hook-form may run BEFORE all fields have been registered, especially if the queryResult is already cached.
Somehow the useEffect to call the setValue with the queryResult data needs to be called for values that may not be registered yet OR when registered, the useEffect needs to run again.
Steps To Reproduce
- useForm hook from @refinedev/react-hook-form
- action is edit mode
- go to edit page once
- return to list
- go to same edit page a second time, which should use the queryClient cache
Expected behavior
The field values from the query result should be set for all registered field values after rendering.
Packages
├─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] │ └─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] └─ @refinedev/[email protected] ├─ @refinedev/[email protected] ├─ @refinedev/[email protected] └─ @refinedev/[email protected]
Additional Context
I'm going to have to come up with a work around for now. I havent came up with one yet that makes sense.