Created
November 29, 2023 13:25
-
-
Save jacobjuul/f76fa342fd252036a2d366fe9f435e8f to your computer and use it in GitHub Desktop.
Mutations with inferred types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Explicit types | |
export const useCreateDocumentBookmarkMutation = ( | |
options: UseMutationOptions<UserAlertOld, unknown, CreateDocumentBookmarkArgs> | |
): UseMutationResult<UserAlertOld, unknown, CreateDocumentBookmarkArgs> => | |
useMutation({ | |
mutationFn: params => addDocumentBookmark(params), | |
onSuccess: () => { | |
queryClient.invalidateQueries([queryKeys.documentBookmarks]) | |
}, | |
...options | |
}) | |
// inferred types | |
export const useCreateDocumentBookmarkMutation = () => // instead of spreading ...options, be specific about what you want | |
useMutation({ | |
mutationFn: (params: CreateDocumentBookmarkArgs) => | |
addDocumentBookmark(params), | |
onSuccess: () => { | |
queryClient.invalidateQueries([queryKeys.documentBookmarks]) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment