-
I have an ID Now, this ID must be passed to mutation hook like that: export function useInit() {
const { tenant } = useTenant();
const tenantID = tenant?.id;
const { mutate } = useMutation(
(data) => init({ ...data, tenantID }),
{
onMutate: (variables) => {
if (!tenantID) throw new Error('Tenant ID is empty');
},
},
);
return mutation;
} I want to make sure that Are there any side effects that I am not aware of or other ways to deal with this dependency? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
I would just not invoke |
Beta Was this translation helpful? Give feedback.
I would just not invoke
mutate
if the id is undefined. But I think your approach works as well.