Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): mutation hooks should accept MutateFunction params as a prop #6116

Conversation

alicanerdurmaz
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

mutation hooks are works like this:

import { useUpdate } from "@refinedev/core";

const { mutate } = useUpdate();

mutate(
  {
    resource: "products",
    id: 1,
    mutationMode: "optimistic",
    successNotification: false,
    values: {
      name: "New Product",
      material: "Wood",
    },
  },
  {
    onSuccess: () => {
      /* do something after mutation success */
    },
  },
);

What is the new behavior?

from now on also works this way to improve the developer experience:

import { useUpdate } from "@refinedev/core";

const { mutate } = useUpdate({
  resource: "products",
  id: 1,
  values: {
    name: "New Product",
    material: "Wood",
  },
  successNotification: false,
  mutationMode: "optimistic",
  mutationOptions: {
    onSuccess: () => {
      /* do something after mutation success */
    },
  },
});

mutate({
  // also you can override the parameters given to the hook
});

fixes #6102 #6113 #6114 #6115

Copy link

changeset-bot bot commented Jul 9, 2024

🦋 Changeset detected

Latest commit: 2723556

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jul 9, 2024

@github-actions github-actions bot temporarily deployed to deploy-preview-pixels-6116/merge July 9, 2024 10:10 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-client-6116/merge July 9, 2024 10:10 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-antd-6116/merge July 9, 2024 10:10 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-app-crm-6116/merge July 9, 2024 10:10 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-pixels-6116/merge July 9, 2024 11:03 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-antd-6116/merge July 9, 2024 11:04 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-material-ui-6116/merge July 9, 2024 11:04 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-app-crm-6116/merge July 9, 2024 11:04 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-client-6116/merge July 9, 2024 11:04 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-6116 July 9, 2024 11:21 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-client-6116/merge July 9, 2024 12:25 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-pixels-6116/merge July 9, 2024 12:25 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-antd-6116/merge July 9, 2024 12:25 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-material-ui-6116/merge July 9, 2024 12:25 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-app-crm-6116/merge July 9, 2024 12:25 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-client-6116/merge July 9, 2024 12:30 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-antd-6116/merge July 9, 2024 12:30 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-pixels-6116/merge July 9, 2024 12:30 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-app-crm-6116/merge July 30, 2024 09:11 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-6116 July 30, 2024 09:30 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-pixels-6116/merge July 30, 2024 11:06 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-client-6116/merge July 30, 2024 11:06 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-antd-6116/merge July 30, 2024 11:06 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-app-crm-6116/merge July 30, 2024 11:06 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-material-ui-6116/merge July 30, 2024 11:06 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-6116 July 30, 2024 11:27 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-pixels-6116/merge July 30, 2024 15:35 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-antd-6116/merge July 30, 2024 15:35 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-material-ui-6116/merge July 30, 2024 15:35 Inactive
@github-actions github-actions bot temporarily deployed to deploy-preview-finefoods-client-6116/merge July 30, 2024 15:35 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-6116 July 30, 2024 15:54 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants