useRefreshRowButton
Returns a refresh row data function, and the current loading status of the data object found in the DataObjectContext
Usage
This is the implementation of the RefreshRowIconButton component in the appframe-mui package.
import { forwardRef } from "react";
import {
Box,
CircularProgress,
IconButton,
IconButtonProps,
} from "@mui/material";
import { getLocalizedString } from "@olenbetong/appframe-core";
import { useRefreshRowButton } from "@olenbetong/appframe-react";
import Refresh from "./icons/Refresh.js";
export const RefreshRowIconButton = forwardRef<
HTMLButtonElement,
IconButtonProps
>(function RefreshRowIconButton({ children, ...props }, ref) {
let { refreshRow, loading } = useRefreshRowButton();
return (
<Box position="relative">
<IconButton
aria-label={getLocalizedString("Refresh current row")}
onClick={() => refreshRow()}
{...props}
ref={ref}
>
{children ?? <Refresh />}
</IconButton>
{loading && (
<CircularProgress
sx={{ position: "absolute", top: 0, left: 0 }}
size={36}
/>
)}
</Box>
);
});API
Last updated
Was this helpful?