@snort/system-react package
This commit is contained in:
10
packages/system-react/src/useSystemState.tsx
Normal file
10
packages/system-react/src/useSystemState.tsx
Normal 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()
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user