Hi Tomasz,
Based on your request, you can prevent the unnecessary
re-renders by wrapping the Grid component with “React.memo()”
higher-order component. Please find the below code snippet for implementation.
|
import React from 'react';
import { GridComponent, ColumnsDirective,
ColumnDirective } from '@syncfusion/ej2-react-grids';
const MyGridComponent = React.memo(({ data }) => {
return (
<GridComponent
dataSource={data}>
<ColumnsDirective>
{/* Define
your grid columns here */}
<ColumnDirective field="id" headerText="ID"
width="100" />
<ColumnDirective field="name" headerText="Name"
width="150" />
{/* Add more
columns as needed */}
</ColumnsDirective>
</GridComponent>
);
});
export default MyGridComponent;
|
In this example, MyGridComponent is wrapped with
React.memo(), which will prevent rerendering if the data prop remains the same.
The grid will only update when the data prop changes.
Please let us know if you have any further queries.
Regards,
Santhosh I