();
+ const isWrapepdWithReactFlowProvider = easyPeasyStore?.getState()?.reactFlowVersion;
+
+ if (isWrapepdWithReactFlowProvider) {
+ // we need to wrap it with a fragment because t's not allowed for children to be a ReactNode
+ // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18051
+ return <>{children}>;
+ }
+
+ return {children};
+};
+
+Wrapper.displayName = 'ReactFlowWrapper';
+
+export default Wrapper;
diff --git a/src/container/ReactFlow/index.tsx b/src/container/ReactFlow/index.tsx
index de742138..82baff23 100644
--- a/src/container/ReactFlow/index.tsx
+++ b/src/container/ReactFlow/index.tsx
@@ -1,6 +1,5 @@
import React, { useMemo, CSSProperties, HTMLAttributes } from 'react';
import cx from 'classnames';
-import { StoreProvider } from 'easy-peasy';
const nodeEnv: string = process.env.NODE_ENV as string;
@@ -19,7 +18,7 @@ import BezierEdge from '../../components/Edges/BezierEdge';
import StraightEdge from '../../components/Edges/StraightEdge';
import StepEdge from '../../components/Edges/StepEdge';
import { createEdgeTypes } from '../EdgeRenderer/utils';
-import store from '../../store';
+import Wrapper from './Wrapper';
import {
Elements,
NodeTypesType,
@@ -92,7 +91,7 @@ const ReactFlow = ({
return (
-
+
{onSelectionChange && }
{children}
-
+
);
};
diff --git a/src/custom.d.ts b/src/custom.d.ts
index 52c9c30a..41d5c1c7 100644
--- a/src/custom.d.ts
+++ b/src/custom.d.ts
@@ -3,8 +3,7 @@ declare module '*.css' {
export default content;
}
-interface SvgrComponent
- extends React.StatelessComponent> {}
+interface SvgrComponent extends React.StatelessComponent> {}
declare module '*.svg' {
const svgUrl: string;
@@ -12,3 +11,5 @@ declare module '*.svg' {
export default svgUrl;
export { svgComponent as ReactComponent };
}
+
+declare var __REACT_FLOW_VERSION__: string;
diff --git a/src/store/index.ts b/src/store/index.ts
index b0d00dc8..ca68b3d0 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -19,6 +19,7 @@ import {
SelectionRect,
HandleType,
SetConnectionId,
+ NodePosUpdate,
} from '../types';
type TransformXYK = {
@@ -27,11 +28,6 @@ type TransformXYK = {
k: number;
};
-type NodePosUpdate = {
- id: ElementId;
- pos: XYPosition;
-};
-
type NodeDimensionUpdate = {
id: ElementId;
nodeElement: HTMLDivElement;
@@ -87,6 +83,8 @@ export interface StoreModel {
isInteractive: boolean;
+ reactFlowVersion: string;
+
onConnect: OnConnectFunc;
setOnConnect: Action;
@@ -126,7 +124,7 @@ export interface StoreModel {
unsetUserSelection: Action;
}
-const storeModel: StoreModel = {
+export const storeModel: StoreModel = {
width: 0,
height: 0,
transform: [0, 0, 1],
@@ -163,6 +161,8 @@ const storeModel: StoreModel = {
isInteractive: true,
+ reactFlowVersion: __REACT_FLOW_VERSION__,
+
onConnect: () => {},
setOnConnect: action((state, onConnect) => {
diff --git a/src/types/index.ts b/src/types/index.ts
index 046a0971..859d2727 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -203,3 +203,8 @@ export interface EdgeTextProps {
labelShowBg?: boolean;
labelBgStyle?: CSSProperties;
}
+
+export type NodePosUpdate = {
+ id: ElementId;
+ pos: XYPosition;
+};