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): add optimisticUpdateMap prop on useUpdate, useUpdateMany and useForm #4914

Merged
merged 33 commits into from
Sep 19, 2023

Conversation

yildirayunlu
Copy link
Contributor

If the mutation mode is defined as optimistic the useUpdate hook will automatically update the cache without waiting for the response from the server. You may want to disable or customize this behavior. You can do this by passing the optimisticUpdateMap prop.

list, many and detail are the keys of the optimisticUpdateMap object. For automatically updating the cache, you should pass the true. If you want not update the cache, you should pass the false.

const { mutate } = useUpdate();

mutate({
    //...
    mutationMode: "optimistic",
    optimisticUpdateMap: {
        list: true,
        many: true,
        detail: false,
    },
});

For useForm:

const { formProps, saveButtonProps } = useForm({
        mutationMode: "optimistic",
        optimisticUpdateMap: {
            list: true,
            many: true,
            detail: (previous, values, id) => {
                if (!previous) {
                    return null;
                }

                const data = {
                    id,
                    ...previous.data,
                    ...values,
                    foo: `bar-one`,
                };

                return {
                    ...previous,
                    data,
                };
            },
        },
    });

Self Check before Merge

Please check all items below before review.

  • Corresponding issues are created/updated or not needed
  • Docs are updated/provided or not needed
  • Examples are updated/provided or not needed
  • TypeScript definitions are updated/provided or not needed
  • Tests are updated/provided or not needed
  • Changesets are provided or not needed

@changeset-bot
Copy link

changeset-bot bot commented Sep 6, 2023

🦋 Changeset detected

Latest commit: 6c57ef1

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

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

@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for lighthearted-pastelito-e86ad1 ready!

Name Link
🔨 Latest commit 6c57ef1
🔍 Latest deploy log https://app.netlify.com/sites/lighthearted-pastelito-e86ad1/deploys/6509ca95a2dc010008847026
😎 Deploy Preview https://deploy-preview-4914--lighthearted-pastelito-e86ad1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for refine-doc-live-previews ready!

Name Link
🔨 Latest commit 6c57ef1
🔍 Latest deploy log https://app.netlify.com/sites/refine-doc-live-previews/deploys/6509ca959240190007b49ae8
😎 Deploy Preview https://deploy-preview-4914--refine-doc-live-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for imaginative-sundae-1fd394 ready!

Name Link
🔨 Latest commit 6c57ef1
🔍 Latest deploy log https://app.netlify.com/sites/imaginative-sundae-1fd394/deploys/6509ca95a288990008eeb146
😎 Deploy Preview https://deploy-preview-4914--imaginative-sundae-1fd394.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@nx-cloud
Copy link

nx-cloud bot commented Sep 6, 2023

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6c57ef1. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 7 targets

Sent with 💌 from NxCloud.

@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4914 September 6, 2023 07:00 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4914 September 6, 2023 07:01 Inactive
@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for aquamarine-panda-e208bf ready!

Name Link
🔨 Latest commit 6c57ef1
🔍 Latest deploy log https://app.netlify.com/sites/aquamarine-panda-e208bf/deploys/6509ca95d562e9000809a9ca
😎 Deploy Preview https://deploy-preview-4914--aquamarine-panda-e208bf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for zippy-semolina-4ad81e ready!

Name Link
🔨 Latest commit 6c57ef1
🔍 Latest deploy log https://app.netlify.com/sites/zippy-semolina-4ad81e/deploys/6509ca9536f9f30008dedd93
😎 Deploy Preview https://deploy-preview-4914--zippy-semolina-4ad81e.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Sep 6, 2023

Deploy Preview for stupendous-taffy-33f80c ready!

Name Link
🔨 Latest commit 6c57ef1
🔍 Latest deploy log https://app.netlify.com/sites/stupendous-taffy-33f80c/deploys/6509ca95a2dc01000884702b
😎 Deploy Preview https://deploy-preview-4914--stupendous-taffy-33f80c.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@refine-bot refine-bot temporarily deployed to deploy-preview-website-4914 September 6, 2023 07:27 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4914 September 6, 2023 07:34 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4914 September 6, 2023 07:34 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4914 September 6, 2023 07:50 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4914 September 6, 2023 07:50 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4914 September 6, 2023 08:06 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4914 September 6, 2023 08:15 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4914 September 6, 2023 08:17 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4914 September 6, 2023 08:36 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4914 September 19, 2023 14:02 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4914 September 19, 2023 14:02 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4914 September 19, 2023 14:10 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4914 September 19, 2023 14:10 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4914 September 19, 2023 14:36 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4914 September 19, 2023 14:46 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4914 September 19, 2023 14:46 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4914 September 19, 2023 15:03 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-mui-4914 September 19, 2023 15:33 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-antd-4914 September 19, 2023 15:33 Inactive
@refine-bot refine-bot temporarily deployed to deploy-preview-website-4914 September 19, 2023 16:06 Inactive
@omeraplak omeraplak added this pull request to the merge queue Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants