MCPcopy
hub / github.com/puckeditor/puck / useContextStore

Function useContextStore

packages/core/lib/use-context-store.tsx:15–26  ·  view source on GitHub ↗
(
  context: Context<StoreApi<T>>,
  selector: (s: ExtractState<StoreApi<T>>) => U
)

Source from the content-addressed store, hash-verified

13 * Use a Zustand store via context
14 */
15export function useContextStore<T, U>(
16 context: Context<StoreApi<T>>,
17 selector: (s: ExtractState<StoreApi<T>>) => U
18): U {
19 const store = useContext(context);
20
21 if (!store) {
22 throw new Error("useContextStore must be used inside context");
23 }
24
25 return useStore<StoreApi<T>, U>(store, useShallow(selector));
26}
27
28export function createStoreProvider<ValueType>(
29 ContextComponent: Context<StoreApi<ValueType>>

Callers 8

DraggableComponentFunction · 0.90
index.tsxFile · 0.90
VirtualizedDropZoneFunction · 0.90
index.tsxFile · 0.90
useMinEmptyHeightFunction · 0.90
useContentIdsWithPreviewFunction · 0.90
DrawerButtonFunction · 0.90
DrawerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected