Я использую act-redux с хуками , и пытаюсь отобразить данные с помощью ag-grid и бесконечная прокрутка , но мне не повезло.Я сделал много попыток;вот что у меня сейчас -
import React, { useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { fetchItems } from './actions';
import { getItems } from './selectors';
let gridApi = null;
const MyGrid = () => {
const items = useSelector(getItems);
const datasource = {
getRows: ({
startRow,
endRow,
sortModel,
filterModel,
successCallback
}) => {
const pageSize = endRow - startRow;
const pageNumber = Math.floor(startRow / pageSize) + 1;
dispatch(fetchItems({ pageNumber, pageSize }));
// I think ag-grid expects results to come in successCallback,
// but have now way of knowing when they will come in
}
};
const onGridReady = params => {
gridApi = params.api;
};
return (
<>
<div className="ag-theme-balham">
<AgGridReact
reactNext={true}
rowModelType="infinite"
paginationPageSize={100}
cacheOverflowSize={2}
maxConcurrentDatasourceRequests={2}
maxBlocksInCache={2}
getRowNodeId={item => item.id}
datasource={datasource}
// rowData={items}
onGridReady={onGridReady}
defaultColDef={{ sortable: true }}
>
<AgGridColumn headerName="Name" field="name" />
<AgGridColumn headerName="Street" field="street" />
<AgGridColumn headerName="City" field="city" />
<AgGridColumn headerName="Phone" field="phoneNumber" />
</AgGridReact>
</div>
</>
);
};
};