useEventReplay
functionsignature
useEventReplay(storeId): { replay: (snapshot: unknown, events: EventLogEntry[]) => void }Replays events through a store's reducers from a given snapshot.
Parameters
| Name | Type | Description |
|---|---|---|
storeId | null | string | The 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>
);
}