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