Files
snort/packages/system-react/src/useSystemState.tsx
2023-06-16 20:31:33 +01:00

11 lines
323 B
TypeScript

import { useSyncExternalStore } from "react";
import { SystemSnapshot } from "@snort/system";
import { ExternalStore } from "@snort/shared";
export function useSystemState(system: ExternalStore<SystemSnapshot>) {
return useSyncExternalStore<SystemSnapshot>(
cb => system.hook(cb),
() => system.snapshot()
);
}