@ichooss/xflow
Version:
[English (US)](README.md) | 简体中文
14 lines (11 loc) • 413 B
text/typescript
import { useContext } from 'react';
import { useStore } from 'zustand';
import { StoreContext } from '../context';
import type { State, Actions } from '../store';
export const useGraphStore = <T>(selector: (state: State & Actions) => T) => {
const store = useContext(StoreContext);
if (!store) {
throw new Error('can only be get inside the xflow component.');
}
return useStore(store, selector);
};