$44 GRAYBYTE WORDPRESS FILE MANAGER $49

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 172.67.162.162 | ADMIN IP 216.73.216.51
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/bravetechrwanda/itiministry.org/plugins/give/src/Views/Components/ListTable/hooks/

HOME
Current File : /home/bravetechrwanda/itiministry.org/plugins/give/src/Views/Components/ListTable/hooks//lagData.ts
import {useRef, useEffect, useCallback} from 'react';

// SWR middleware for keeping the data even if key changes.
export default function lagData(useSWRNext) {
    return (key, fetcher, config) => {
        // Use a ref to store previous returned data.
        const laggyDataRef = useRef();

        // Actual SWR hook.
        const swr = useSWRNext(key, fetcher, config);

        useEffect(() => {
            // Update ref if data is not undefined.
            if (swr.data !== undefined) {
                laggyDataRef.current = swr.data;
            }
        }, [swr.data]);

        // Expose a method to clear the laggy data, if any.
        const resetLaggy = useCallback(() => {
            laggyDataRef.current = undefined;
        }, []);

        // Fallback to previous data if the current data is undefined.
        const dataOrLaggyData = swr.data === undefined ? laggyDataRef.current : swr.data;

        // Is it showing previous data?
        const isLagging = swr.data === undefined && laggyDataRef.current !== undefined;

        // Also add a `isLagging` field to SWR.
        return Object.assign({}, swr, {
            data: dataOrLaggyData,
            isLagging,
            resetLaggy,
        });
    };
}


Current_dir [ WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 May 2026 4.20 PM
bravetechrwanda / bravetechrwanda
0755
lagData.ts
1.208 KB
19 Jan 2023 12.19 AM
bravetechrwanda / bravetechrwanda
0644
useDebounce.ts
0.335 KB
31 Mar 2025 11.17 PM
bravetechrwanda / bravetechrwanda
0644
useDebouncedEventHandler.ts
0.282 KB
19 Jan 2023 12.19 AM
bravetechrwanda / bravetechrwanda
0644
useFallbackAsInitial.ts
0.768 KB
19 Jan 2023 12.19 AM
bravetechrwanda / bravetechrwanda
0644
useResetPage.ts
0.459 KB
19 Jan 2023 12.19 AM
bravetechrwanda / bravetechrwanda
0644
useUniqueId.ts
0.186 KB
12 May 2022 3.49 AM
bravetechrwanda / bravetechrwanda
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF Static GIF