Add shouldRender prop to table
This commit is contained in:
1 parent
cdc407fd21
commit
016cd69763
1 file changed
+7
@@ -7,6 +7,7 @@ import {
|
|||||||
TableHead,
|
TableHead,
|
||||||
TableRow,
|
TableRow,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import SkeletonLayout from "./skeleton";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ import { useTheme } from "@emotion/react";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const DataTable = ({
|
const DataTable = ({
|
||||||
|
shouldRender = true,
|
||||||
headers = [],
|
headers = [],
|
||||||
data = [],
|
data = [],
|
||||||
config = {
|
config = {
|
||||||
@@ -41,6 +43,10 @@ const DataTable = ({
|
|||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
if (!shouldRender) {
|
||||||
|
return <SkeletonLayout />;
|
||||||
|
}
|
||||||
|
|
||||||
if ((headers?.length ?? 0) === 0) {
|
if ((headers?.length ?? 0) === 0) {
|
||||||
return "No data";
|
return "No data";
|
||||||
}
|
}
|
||||||
@@ -117,6 +123,7 @@ const DataTable = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
DataTable.propTypes = {
|
DataTable.propTypes = {
|
||||||
|
shouldRender: PropTypes.bool,
|
||||||
headers: PropTypes.arrayOf(
|
headers: PropTypes.arrayOf(
|
||||||
PropTypes.shape({
|
PropTypes.shape({
|
||||||
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
||||||
|
|||||||
Reference in new issue
Block a user