import { useSyncExternalStore } from "react";
import { getState, subscribe, type State } from "./store";

// Subscribe a component to the local-first store. The whole state object is
// the snapshot (replaced immutably on every change), so derive lists inline.
export function useStore(): State {
  return useSyncExternalStore(subscribe, getState, getState);
}
