feat(view): add read-only app state hook
This commit is contained in:
7
view/useAppState.ts
Normal file
7
view/useAppState.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import type { AppStore } from "@editor/store";
|
||||
import type { AppState } from "@editor/state";
|
||||
|
||||
export function useAppState(store: AppStore): AppState {
|
||||
return useSyncExternalStore(store.subscribe, store.getState, store.getState);
|
||||
}
|
||||
Reference in New Issue
Block a user