Skip to main content
Refine AI
Version: 4.xx.xx
Swizzle Ready

Refresh

<RefreshButton> uses Material UI <Button> component to update the data shown on the page via the useInvalidate hook.

Good to know:

You can swizzle this component with the Refine CLI to customize it.

Usage

localhost:3000/posts
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. By default, recordItemId will be inferred from the route.

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

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".

resource

resource allows us to manage which resource is going to be refreshed. By default, <RefreshButton> uses the inferred resource from the route.

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

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".

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 section of the <Refine/> component documentation

hideText

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

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

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

resourceNameOrRouteName
deprecated

Use the resource prop instead.

API Reference

Properties

PropertyTypeDescriptionDefault
hideText

boolean

Whether should hide the text and show only the icon or not.

false

resourceNameOrRouteName

Please use resource instead.

string

Resource name for API data interactions

Reads :resource from the URL

resource

string

Resource name for API data interactions. identifier of the resource can be used instead of the name of the resource.

Inferred resource name from the route

accessControl

{ enabled?: boolean; hideIfUnauthorized?: boolean; }

undefined

Access Control configuration for the button

{ enabled: true }

recordItemId

Data item identifier for the actions with the API

Reads :id from the URL

dataProviderName

string

onClick

(PointerEventHandler<HTMLButtonElement> & MouseEventHandler<HTMLButtonElement>)

Sets the handler to handle click event

svgIconProps

SvgIconProps

meta

meta is deprecated with refine@4, <RefreshButton /> will use useInvalidates instead of useOne.

MetaQuery

meta is deprecated with refine@4, <RefreshButton /> will use useInvalidates instead of useOne.

metaData

metaData is deprecated with refine@4, <RefreshButton /> will use useInvalidates instead of useOne.

MetaQuery

metaData is deprecated with refine@4, <RefreshButton /> will use useInvalidates instead of useOne.

External Props:

It also accepts all props of Material UI Button.