feat(react): infer node types from passed nodes
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
|
||||
import { useReactFlow } from './useReactFlow';
|
||||
import type { OnInit } from '../types';
|
||||
import type { OnInit, Node } from '../types';
|
||||
|
||||
/**
|
||||
* Hook for calling onInit handler.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export function useOnInitHandler(onInit: OnInit | undefined) {
|
||||
const rfInstance = useReactFlow();
|
||||
export function useOnInitHandler<NodeType extends Node = Node>(onInit: OnInit<NodeType> | undefined) {
|
||||
const rfInstance = useReactFlow<NodeType>();
|
||||
const isInitialized = useRef<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user