diff --git a/packages/core/src/container/ReactFlow/Wrapper.tsx b/packages/core/src/container/ReactFlow/Wrapper.tsx index 297e3b49..b6069948 100644 --- a/packages/core/src/container/ReactFlow/Wrapper.tsx +++ b/packages/core/src/container/ReactFlow/Wrapper.tsx @@ -1,18 +1,10 @@ -import type { FC, PropsWithChildren } from 'react'; +import { FC, PropsWithChildren, useContext } from 'react'; -import { useStoreApi } from '../../hooks/useStore'; +import StoreContext from '../../contexts/RFStoreContext'; import ReactFlowProvider from '../../components/ReactFlowProvider'; const Wrapper: FC = ({ children }) => { - let isWrapped = true; - - try { - useStoreApi(); - } catch (e) { - isWrapped = false; - } - - if (isWrapped) { + if (useContext(StoreContext)) { // we need to wrap it with a fragment because it's not allowed for children to be a ReactNode // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18051 return <>{children};