@snort/system-react package

This commit is contained in:
2023-06-16 20:31:33 +01:00
parent 28052e98b9
commit 939084167a
47 changed files with 334 additions and 122 deletions

View File

@ -0,0 +1,10 @@
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()
);
}