refactor(node-toolbar): define zustand selector outside of the component

This commit is contained in:
moklick
2022-11-16 18:28:25 +01:00
parent 96e53e4408
commit 1841dfa2ca
@@ -2,8 +2,10 @@ import { ReactNode } from 'react';
import { createPortal } from 'react-dom';
import { ReactFlowState, useStore } from '@reactflow/core';
const selector = (state: ReactFlowState) => state.domNode?.querySelector('.react-flow__renderer');
function NodeToolbarPortal({ children }: { children: ReactNode }) {
const wrapperRef = useStore((state: ReactFlowState) => state.domNode?.querySelector('.react-flow__renderer'));
const wrapperRef = useStore(selector);
if (!wrapperRef) {
return null;