TanStackT
TanStack2y ago
4 replies
few-sapphire

Trigger useQueries fnc in onSuccess of other func, but queryOptions fnc has diff queryKey

export const useFetchDataScreen = (id:number):any => { const assignDataFn = (id: number) => { return queryOptions({ queryKey: ['assignKey',id], queryFn: () => getAssign(id), enabled:!!id }) } const getRoles = () => { return queryOptions({ queryKey: ['getRoleUser], queryFn: () => getRolesUser(), enabled:!!roleId }) } return useQueries({ queries: [assignDataFn(id), getRoles() ], combine:([{data:permissionOfRoles}, roles, allPermissions])=> { //// logic and return data }, }) };

this is first fn to render data


and this is the func i need to help:

export const useAssignRoleForPermission = (roleId:number) => return useMutation({ mutationFn: (payload:any) => postFn(payload), mutationKey:['post_fn_key'], onSuccess:() => { // i need call useFetchDataScreen in here } }) }
Was this page helpful?