I am using ResponsiveGridLayout from "react-grid-layout" and MaterialReactTable from "material-react-table".at first I shows just 5 rows of table but when I resize the div that has GalleryItem I want to show 10 rows of table. 10 is set for pageSize but the table did not rerender and did not shows 10 rows.how can I show 10 rows of table when the height of div increases by resizing and show 5 rows of table when the height of div is its initial value?
const Gallery = () => {
const [pageSize, setPageSize] = useState<number>(5);
const handleResize = (items: any) => {
items
.forEach((item: any) => {
if (item.h === 2) {
setContentHeight("850px");
setPageSize(() => 10);
} else if (item.h === 1) {
setContentHeight("350px");
setPageSize(() => 5);
}
});
};
return ( <ResponsiveGridLayout
layouts={{
lg: defaultLayout,
}}
rowHeight={rowHeight}
cols={{
lg: 6,
md: 2,
sm: 2,
xs: 1,
xxs: 1,
}}
breakpoints={{
lg: 1200,
md: 996,
sm: 768,
xs: 480,
xxs: 0,
}}
resizeHandles={["e", "w", "s"]}
onResizeStop={handleResize}
>
{galleries.map((item) => (
<div key={item.id}>
<GalleryItem
messageItem={item}
contentHeight={contentHeight}
pageSize={pageSize}
/>
</div>
))}
</ResponsiveGridLayout>
)
}
GalleryItem:
const GalleryItem = ({
pageSize,
})=>{
return ( <Table pageSize={pageSize} data={data} props={props} />)
}
Table:
const Table = ({ data, props ,pageSize}) => {
return (
<MaterialReactTable
columns={columns}
data={data}
{...props}
/>
);
};
in Gallery, I should define pageSize for each key and and key is the id of each gallery item.
in Table component I should apply the below changes: