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 Nov 11, 2023. It is now read-only.
I'm trying to use a mutate function inside a useEffect. Since I have the exhaustive-deps lint rule, i need to add this function to the depency list in my effect. But the mutate function reference is changing every render and is triggering my effect.
To work around this I had to memoize the mutation in a useCallback and used that as a depedency instead. Is this the expected path to take? It seems like a lot of overhead. Given the same args, shouldn't we receive the same reference from useMutate in every render?
The text was updated successfully, but these errors were encountered:
omegafranco
changed the title
useMutate inside a useEffect
Mutation function inside a useEffect
Jan 7, 2021
Hello, thanks for the reporting, this is probably the same kind of mess than this issue #186
Sadly I don't have any quick win / time for this right know, but I totally agree that this can be an issue! So yeah, for now, eslint ignore or useCallback is the way to go. Sorry for the overhead 😕
I'm trying to use a mutate function inside a useEffect. Since I have the exhaustive-deps lint rule, i need to add this function to the depency list in my effect. But the mutate function reference is changing every render and is triggering my effect.
To work around this I had to memoize the mutation in a useCallback and used that as a depedency instead. Is this the expected path to take? It seems like a lot of overhead. Given the same args, shouldn't we receive the same reference from useMutate in every render?
The text was updated successfully, but these errors were encountered: