Skip to main content

useAddProjectMutation

The useAddProjectMutation hook uses the useMutation hook from React Query to handle the addition of a project.

Components

mutationFn: addProject:

This is the function that will be called when the mutation is triggered. It's expected to return a Promise.

onSuccess: () => { ... }:

This is a callback function that will be called if the mutation is successful. It invalidates (or refetches) all queries associated with the key projectQueryKeys.all.

onError: (error) => { ... }:

This is a callback function that will be called if the mutation encounters an error. It's currently commented out, but you could use it to handle any errors that occur during the mutation.

Behavior

The hook returns the addProjectMutation object, which includes methods to trigger the mutation (mutate, mutateAsync), as well as properties that describe the state of the mutation (isLoading, isError, data, error, etc.).