@matthewgapp/solidjs-flow
Version:
React Flow - A highly customizable React library for building node-based editors and interactive flow charts.
20 lines (15 loc) • 515 B
text/typescript
import { useStore } from './useStore';
import type { Edge, SolidFlowState } from '../types';
import { Writable } from '../store/initialState';
const edgesSelector = (state: SolidFlowState) => state.edges;
/**
* Hook for getting the current edges from the store.
*
* @public
* @returns An array of edges
*/
export function useEdges<EdgeType extends Edge = Edge>(): Writable<EdgeType[]> {
// TODO: fix this cast
const edges = useStore(edgesSelector) as unknown as Writable<EdgeType[]>;
return edges;
}