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
Now, the useListPetsHook will return the same reference on subsequent calls (given that your useCustomInstance doesn't change of course).
A stable reference is useful when one uses memoization downstream, and the result of the useListPetsHook is part of a useMemo or useCallback call in user-land code.
The text was updated successfully, but these errors were encountered:
henkerik
changed the title
Unstable return reference of generated hooks when using a custom mutator hook.
Unstable return reference of generated hook when using a custom mutator hook.
May 7, 2024
What are the steps to reproduce this issue?
First of all, thanks for building Orval. We use it for quite a few projects 馃憤 .
One can generate endpoints with a custom mutator hook, for example:
orval/samples/react-query/hook-mutator/endpoints.ts
Lines 36 to 38 in 4cfb246
What happens?
The reference returned by the generated
useListPetsHook
isn't stable: it changes on every render cycle.What were you expecting to happen?
I would have expected the following:
Now, the
useListPetsHook
will return the same reference on subsequent calls (given that youruseCustomInstance
doesn't change of course).A stable reference is useful when one uses memoization downstream, and the result of the
useListPetsHook
is part of auseMemo
oruseCallback
call in user-land code.The text was updated successfully, but these errors were encountered: