MCPcopy
hub / github.com/claude-code-best/claude-code / useAppState

Function useAppState

src/state/AppState.tsx:129–146  ·  view source on GitHub ↗
(selector: (state: AppState) => T)

Source from the content-addressed store, hash-verified

127 * ```
128 */
129export function useAppState<T>(selector: (state: AppState) => T): T {
130 const store = useAppStore();
131
132 const get = () => {
133 const state = store.getState();
134 const selected = selector(state);
135
136 if (process.env.USER_TYPE === 'ant' && state === selected) {
137 throw new Error(
138 `Your selector in \`useAppState(${selector.toString()})\` returned the original state, which is not allowed. You must instead return a property for optimised rendering.`,
139 );
140 }
141
142 return selected;
143 };
144
145 return useSyncExternalStore(store.subscribe, get, get);
146}
147
148/**
149 * Get the setAppState updater without subscribing to any state.

Callers 15

SessionBackgroundHintFunction · 0.85
CoordinatorTaskPanelFunction · 0.85
useCoordinatorTaskCountFunction · 0.85
StatusLineInnerFunction · 0.85
ModelPickerFunction · 0.85
MessageSelectorFunction · 0.85
BridgeDialogFunction · 0.85
TeammateViewHeaderFunction · 0.85
ThemePickerFunction · 0.85
SpinnerWithVerbFunction · 0.85
SpinnerWithVerbInnerFunction · 0.85
BriefSpinnerFunction · 0.85

Calls 1

useAppStoreFunction · 0.85

Tested by

no test coverage detected