( context: Context<StoreApi<T>>, selector: (s: ExtractState<StoreApi<T>>) => U )
| 13 | * Use a Zustand store via context |
| 14 | */ |
| 15 | export 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 | |
| 28 | export function createStoreProvider<ValueType>( |
| 29 | ContextComponent: Context<StoreApi<ValueType>> |
no outgoing calls
no test coverage detected