Co-authored-by: SolitaryThinker <wlsaidhi@gmail.com> Co-authored-by: Matthew Noto <99706358+RandNMR73@users.noreply.github.com> Co-authored-by: XOR-op <17672363+XOR-op@users.noreply.github.com> Co-authored-by: Zhang Peiyuan <42993249+jzhang38@users.noreply.github.com>
12 lines
262 B
TypeScript
12 lines
262 B
TypeScript
'use client';
|
|
|
|
import { useSyncExternalStore } from 'react';
|
|
|
|
import type { ManagedStore } from '@/stores/createManagedStore';
|
|
|
|
export function useStore<T>(
|
|
store: ManagedStore<T>,
|
|
): T {
|
|
return useSyncExternalStore(store.subscribe, store.get, store.get);
|
|
}
|