@xyflow/svelte
Version:
Svelte Flow - A highly customizable Svelte library for building node-based editors, workflow systems, diagrams and more.
22 lines (21 loc) • 514 B
JavaScript
import { useStore } from '../store';
/**
* Hook to get an internal node by id.
*
* @public
* @param id - the node id
* @returns An internal node or undefined
*/
export function useInternalNode(id) {
const { nodeLookup, nodes } = $derived(useStore());
const node = $derived.by(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
nodes;
return nodeLookup.get(id);
});
return {
get current() {
return node;
}
};
}