Replies: 1 comment 2 replies
-
the That being said, I don't understand your example for various reasons, and I don't know how you would initialize something with a useEffect?
to avoid that, either just pass
because it is stable, or move the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
So, when I call useMutation in the body of my component, this will cause all children to rerender on every rerender because the returned mutation function changes on every rerender. Should I initialize the mutation in a useEffect or is there another way of preventing all children of rerendering?
`
const queryClient = useQueryClient()
const mutateDelete = useMutation(
({ path }) =>
deleteFileByPath(path),
{
onSettled: (data, error, variables, context) =>
invalidateUserStudys(queryClient),
}
);
return (
<OtherComponent onClick={(path)=>mutateDelete.mutate({path})} />
)
`
Beta Was this translation helpful? Give feedback.
All reactions