Skip to main content
Version: 4.xx.xxSwizzle Ready

Refresh

<RefreshButton> uses Material UI <Button> component to update the data shown on the page via the useOne method provided by your dataProvider.

Swizzle

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

Usage

http://localhost:3000
import { useShow } from "@refinedev/core";
import { Show, RefreshButton } from "@refinedev/mui";
import { Typography, Stack } from "@mui/material";

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

return (
<Show
isLoading={isLoading}
headerButtons={
<RefreshButton />
}
>
<Typography fontWeight="bold">Id</Typography>
<Typography>{record?.id}</Typography>
<Typography fontWeight="bold">Title</Typography>
<Typography>{record?.title}</Typography>
</Show>
);
};

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

Properties

recordItemId

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

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

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

Clicking the button will trigger the useOne method and then fetches 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.

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

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

Clicking the button will trigger the useOne method 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.

hideText

It is used to show and not show the text of the button. When true, only the button icon is visible.

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

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

resourceNameOrRouteName
deprecated

resourceNameOrRouteName prop is deprecated. Use resource prop instead.

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

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

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

Clicking the button will trigger the useOne method 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 Material UI Button.