I am passing data in the MemoDownloadsSubTab component but when I am trying to use it in MemoDownloadsSubTab in useMemo I am getting error data that is not defined I am not sure why this is happening let me know what I need to change so any another way I need to pass data in parent to child and us in the child component.
export const CorporateDetailsTable = ({
userHistorySummary,
}) => {
const MemoDownloadsSubTab = React.useMemo(
({ data = [] }) => {
return (
<>
{data?.length !== 0 &&
data?.map((row, rowIndex) => {
return (
<Box bgcolor="mainDetailsCard.primary" m={1} p={1} borderRadius={5}>
<Grid xs={12} item container spacing={2}>
<Grid item xs={12} sm={3}>
<Typography component="div">
<Box fontWeight="fontWeightBold" component="span" mr={1}>
SRN :
</Box>
{row.SRN}
</Typography>
</Grid>
<Grid item xs={12} sm={3}>
<Typography component="div">
<Box fontWeight="fontWeightBold" component="span" mr={1}>
Charge ID :
</Box>
{row.CHARGE_ID ? row.CHARGE_ID : "N/A"}
</Typography>
</Grid>
</Grid>
</Box>
);
})}
</>
);
}
,[userHistorySummary?.charges]);
return (
<>
{userHistorySummary?.masterData?.length !== 0 ? (
<Box mt={1}>
return (
<MemoDownloadsSubTab
data={userHistorySummary?.charges}
title={"Charges Registered"}
cells={chargesCells}
classes={classes}
/>
</Box>
) : (
<Typography variant="subtitle1" color="textSecondary">
No Data Available
</Typography>
)}
</>
);
};