Skip to main content
πŸ‘€ Interested in the latest enterprise backend features of refine? πŸ‘‰ Join now and get early access!
Version: 4.xx.xx
Swizzle Ready

Refresh

<RefreshButton> uses Ant Design's <Button> component to update the data shown on the page via the useInvalidate hook.

Swizzle

You can swizzle this component to customize it with the refine CLI

Usage​

localhost:3000
import { useShow } from "@refinedev/core";
import {
RefreshButton,
Show,
} from "@refinedev/antd";
import { Typography } from "antd";

const { Title, Text } = Typography;

const PostShow: React.FC = () => {
const { queryResult } = useShow<IPost>();
const { data, isLoading } = queryResult;
const record = data?.data;

return (
<Show
isLoading={isLoading}
headerButtons={<RefreshButton />}
>
<Title level={5}>Id</Title>
<Text>{record?.id}</Text>

<Title level={5}>Title</Title>
<Text>{record?.title}</Text>
</Show>
);
};

interface IPost {
id: string;
title: string;
}

Properties​

recordItemId​

recordItemId allows us to manage which data is going to be refreshed.

localhost:3000
import { RefreshButton } from "@refinedev/antd";

const MyRefreshComponent = () => {
return (
<RefreshButton
resource="posts"
recordItemId="1"
/>
);
};

Clicking the button will trigger the useInvalidate hook and then fetch the record whose resource is "post" and whose id is "1".

NOTE

<RefreshButton> component reads the id information from the route by default.

resource​

resource allows us to manage which resource is going to be refreshed.

localhost:3000
import { RefreshButton } from "@refinedev/antd";

const MyRefreshComponent = () => {
return (
<RefreshButton
resource="categories"
recordItemId="2"
/>
);
};

Clicking the button will trigger the useInvalidate hook and then fetches the record whose resource is "categories" and whose id is "2".

NOTE

<RefreshButton> component reads the resource name from the route by default.

If you have multiple resources with the same name, you can pass the identifier instead of the name of the resource. It will only be used as the main matching key for the resource, data provider methods will still work with the name of the resource defined in the <Refine/> component.

For more information, refer to the identifier of the <Refine/> component documentation β†’

hideText​

hideText is used to hide the text of the button. When its true, only the button icon will be visible.

localhost:3000
import { RefreshButton } from "@refinedev/antd";

const MyRefreshComponent = () => {
return (
<RefreshButton
hideText
/>
);
};

resourceNameOrRouteName
deprecated
​

resourceNameOrRouteName prop is deprecated. Use resource prop instead.

resourceNameOrRouteName allows us to manage which resource is going to be refreshed.

localhost:3000
import { RefreshButton } from "@refinedev/antd";

const MyRefreshComponent = () => {
return (
<RefreshButton
resourceNameOrRouteName="categories"
recordItemId="2"
/>
);
};

Clicking the button will trigger the useInvalidate hook and then fetches the record whose resource is "categories" and whose id is "2".

NOTE

<RefreshButton> component reads the resource name from the route by default.

API Reference​

Properties​

External Props

It also accepts all props of Ant Design Button.