mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-01-09 19:15:38 +00:00
Fix loading new rows logic
This commit is contained in:
parent
91d5b8f86b
commit
a8579ef34b
@ -571,7 +571,34 @@ function Row({ data, index }: { data: DataType | undefined, index: number }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function LogsTerminal() {
|
function LogsTerminal() {
|
||||||
|
const [data, setData] = useState<DataType[]>([]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setData(exampleData.concat(Array.from({ length: 500 - exampleData.length }).map(_ => undefined)));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const isItemLoaded = (index: number) => index < data.length && data[index] !== undefined;
|
||||||
|
|
||||||
|
const loadMoreItems = (startIndex: number, stopIndex: number) => {
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
setData(prevData => {
|
||||||
|
const newData = [...prevData];
|
||||||
|
for (let i = startIndex; i <= stopIndex; i++) {
|
||||||
|
if (!newData[i]) {
|
||||||
|
|
||||||
|
newData[i] = { option: `Option ${i}`, description: `Description for ${i}` };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newData;
|
||||||
|
});
|
||||||
|
resolve();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack>
|
<Stack>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user