fix: access the edge-label-renderer by reactflow's id

This commit is contained in:
GeoffreyLiu
2022-11-08 15:46:05 +08:00
parent a9e7411d6d
commit 55cf7560c0
3 changed files with 11 additions and 2 deletions
@@ -1,9 +1,13 @@
import { useRef } from 'react';
import type { ReactNode } from 'react';
import { createPortal } from 'react-dom';
import { useStoreApi } from '../../hooks/useStore';
import { getEdgeLabelRendererId } from '../../utils/graph';
function EdgeLabelRenderer({ children }: { children: ReactNode }) {
const wrapperRef = useRef(document.getElementById('edgelabel-portal'));
const store = useStoreApi()
const state = store.getState()
const wrapperRef = useRef(document.getElementById(getEdgeLabelRendererId(state.rfId)));
if (!wrapperRef.current) {
return null;