La referencia de la API está disponible solo en inglés por ahora.

useEventReplay

function
devtools-ui/src/hooks/useEventReplay.ts:51
signature
useEventReplay(storeId): { replay: (snapshot: unknown, events: EventLogEntry[]) => void }

Replays events through a store's reducers from a given snapshot.

Parameters

NameTypeDescription
storeIdnull | stringThe store ID to replay events on, or null to disable.

Returns

{ replay: (snapshot: unknown, events: EventLogEntry[]) => void }, An object containing the replay function.

Example

example
import { useEventLog, useStoreState, useEventReplay } from "@yoltra/devtools-ui";

function ReplayButton({ storeId }: { storeId: string }) {
  const { state } = useStoreState(storeId);
  const { entries } = useEventLog(storeId);
  const { replay } = useEventReplay(storeId);

  return (
    <button onClick={() => replay(state, entries)}>
      Replay All Events
    </button>
  );
}