Conversation
| </Router> | ||
| </NotificationModalProvider> | ||
| </Web3Provider> | ||
| {isLocalDevMode && <ReactQueryDevtools />} |
|
|
||
| const createCommunityUser = useCallback( | ||
| async (communityId, user, injectedProvider) => { | ||
| const { mutateAsync: createCommunityUserMutation } = useMutation( |
There was a problem hiding this comment.
I had tu use mutateAsync as opposed to mutate because of the way the hook is used in the component. The component is expecting to get a result from the mutation like here: https://github.com/DapperCollectives/CAST/pull/108/files#diff-ba7b9f47b489056dd6b487fee2e4bf14d1d836b8f8de40956a83cd57e1e84b39R34
In the docs: https://react-query.tanstack.com/reference/useMutation retuning the mutate function seems the way to go, they we could use something like:
const { mutate, data, error, isLoading } = useSomeWrapperFunctionMutation(mutate,
{
onSuccess: () => {
manage side effects here; general ones like some query invalidation adding data to loaded queries and so on
}
});
then we can call
mutate(payload);
or if we have specific side effects:
mutate(payload, {
onSuccess: (data, variables, context) => {
// something we need to happen on the component that triggered the update
},
onError: (error, variables, context) => {
// same here
},
onSettled: (data, error, variables, context) => {
// same here
},
})
| // setting this to null and then to a valid address retriggers query to get memberState | ||
| setAddr(null); | ||
| setAddr(user.addr); |
There was a problem hiding this comment.
Initially this was done to make useUserRoleOnCommunity to reload and update memberState.
But becase useUserRoleOnCommunity() uses inside useUserCommunities() that uses onSuccess here to invalidate the query and refetch from the API we don't need to re-trigger the query by reseting one of it's params
… cas-174 # Conflicts: # frontend/packages/client/src/App.js # frontend/packages/client/src/hooks/useUserCommunities.js # frontend/packages/client/src/pages/Home.js

Depends on #97