import { useMutation, useQueryClient } from '@tanstack/react-query';
import { modelenceMutation } from '@modelence/react-query';
function MyComponent() {
const queryClient = useQueryClient();
// Basic usage
const { mutate } = useMutation(modelenceMutation('todos.create'));
// With additional options
const { mutate: updateTodo } = useMutation({
...modelenceMutation('todos.update'),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['todos.getAll'] });
},
});
return <button onClick={() => mutate({ title: 'New Todo' })}>Create</button>;
}