feat(components): add ReactFlowProvider #275

This commit is contained in:
moklick
2020-06-02 18:34:02 +02:00
parent 3f3a79b5f6
commit 5cbeda5c3f
12 changed files with 166 additions and 34 deletions
+21
View File
@@ -0,0 +1,21 @@
import React, { FC } from 'react';
import { StoreProvider, useStore } from 'easy-peasy';
import store, { StoreModel } from '../../store';
const Wrapper: FC = ({ children }) => {
const easyPeasyStore = useStore<StoreModel>();
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 <StoreProvider store={store}>{children}</StoreProvider>;
};
Wrapper.displayName = 'ReactFlowWrapper';
export default Wrapper;