refactor(types): use same structure for nodes and edges

This commit is contained in:
moklick
2024-02-17 15:45:10 +01:00
parent 776f6ce0b7
commit ad7403cc75
24 changed files with 176 additions and 147 deletions
+5 -3
View File
@@ -1,15 +1,17 @@
import { useEffect, useRef } from 'react';
import { useReactFlow } from './useReactFlow';
import type { OnInit, Node } from '../types';
import type { OnInit, Node, Edge } from '../types';
/**
* Hook for calling onInit handler.
*
* @internal
*/
export function useOnInitHandler<NodeType extends Node = Node>(onInit: OnInit<NodeType> | undefined) {
const rfInstance = useReactFlow<NodeType>();
export function useOnInitHandler<NodeType extends Node = Node, EdgeType extends Edge = Edge>(
onInit: OnInit<NodeType, EdgeType> | undefined
) {
const rfInstance = useReactFlow<NodeType, EdgeType>();
const isInitialized = useRef<boolean>(false);
useEffect(() => {