fix and clear code

This commit is contained in:
Hristo Nedelkov 2023-11-08 02:14:36 +02:00
parent 78d79c76da
commit da57a798ca
1 changed files with 8 additions and 10 deletions

View File

@ -35,12 +35,10 @@ const Row: React.FC<RowProps> = ({ data, index }) => {
</Stack>
</XStack>
);
}
function LogsTerminal() {
const [data, setData] = useState<DataType[]>([]);
};
const LogsTerminal: React.FC = () => {
const [data, setData] = useState<(DataType | undefined)[]>([]);
useEffect(() => {
const exampleData: DataType[] =
[
@ -578,19 +576,19 @@ function LogsTerminal() {
},
]
const initialData = [...exampleData, ...Array(500 - exampleData.length).fill(undefined)];
setData(initialData);
}, []);
const isItemLoaded = (index: number) => index < data.length && data[index] !== undefined;
const isItemLoaded = (index: number): boolean => index < data.length && data[index] !== undefined;
const loadMoreItems = (startIndex: number, stopIndex: number) => {
const loadMoreItems = (startIndex: number, stopIndex: number): Promise<void> => {
return new Promise<void>((resolve) => {
setTimeout(() => {
setData(prevData => {
setData((prevData) => {
const newData = [...prevData];
for (let i = startIndex; i <= stopIndex; i++) {
if (!newData[i]) {
newData[i] = { option: `Option ${i}`, description: `Description for ${i}` };
}
}