diff --git a/components/section/data-section/client.tsx b/components/section/data-section/client.tsx index 747ca6208..4ad140339 100644 --- a/components/section/data-section/client.tsx +++ b/components/section/data-section/client.tsx @@ -25,6 +25,7 @@ export function DataSectionClient({ ...props }: IDataSectionClientProps) { const showLoadingState = useShowLoadingState(data); + if (isAPILoading(data) && !showLoadingState) { return
; } @@ -49,19 +50,19 @@ export function DataSectionClient({ /** Contains the logic that prevents flickering of UI */ function useShowLoadingState(data: IAPILoading | T): data is IAPILoading { - const after100ms = useTimeout(100); + const before100ms = !useTimeout(100); const before800ms = !useTimeout(800); const [dataLoadedBefore100ms, setDataLoadedBefore100ms] = useState( - !isAPILoading(data) + before100ms && !isAPILoading(data) ); useEffect(() => { - if (!isAPILoading(data) && !after100ms) { + if (!isAPILoading(data) && before100ms) { setDataLoadedBefore100ms(true); } - }, [data, after100ms]); + }, [data]); - if (dataLoadedBefore100ms) { + if (before100ms || dataLoadedBefore100ms) { return false; } if (before800ms) {