/** * This function is a react hook for loading data and reloading it with a way of * aborting the request. Useful when using reducers to load data asynchronously * and store the state outside of this react hook. * * ## Example * * ```js * import { useLoadDataEffect } from '@oneblink/apps-react' * * const fetchData = async (abortSignal) => { * const response = await fetch( * `https://some-website.com/api?data=data`, * { * signal: abortSignal, * }, * ) * * const data = await response.json() * // store data in a data layer for later use * } * * export default function MyComponent() { * const handleRefresh = useLoadDataEffect(fetchData) * * return * } * ``` * * @param onLoad The function that fetches your data and stores it for later * use. * @returns A function to reload the data * @group Hooks */ export default function useLoadDataEffect(onLoad: (abortSignal: AbortSignal) => void): () => void;