Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 6x 6x 1x | import { useEffect, useRef } from 'react';
import { useLoaderData } from 'react-router';
import { useTaoContext } from '@tao.js/react';
import { createUseSignalEffect, getSignal } from '@tao.js/routing-core';
/** @typedef {import('@tao.js/routing-core').RouteSignal} RouteSignal */
/** @typedef {import('@tao.js/routing-core').LoaderResult} LoaderResult */
/**
* Read the route-entry signal from the current React Router loader data
* (the {@link LoaderResult} `{ signal }` bag an `importLoader` produced).
*
* @returns {RouteSignal | null | undefined}
*/
function useReactRouterSignal() {
const data = useLoaderData();
return getSignal(data);
}
/**
* Apply the `{ signal }` from the current React Router loader data to the Kernel.
*
* @type {import('@tao.js/routing-core').UseSignalEffectHook}
*/
export const useLoaderSignal = createUseSignalEffect({
useEffect,
useRef,
useTaoContext,
useSignal: useReactRouterSignal,
});
|