refactor(state): replace redux with zustand
This commit is contained in:
@@ -1,21 +1,26 @@
|
||||
import React, { FC, useContext, useMemo } from 'react';
|
||||
import { Provider, ReactReduxContext } from 'react-redux';
|
||||
import React, { FC } from 'react';
|
||||
|
||||
import store from '../../store';
|
||||
import { Provider, createStore } from '../../store';
|
||||
// import { ReactFlowState } from '../../types';
|
||||
|
||||
// const reactFlowVersionSelector = (s: ReactFlowState) => s.reactFlowVersion;
|
||||
|
||||
const Wrapper: FC = ({ children }) => {
|
||||
const contextValue = useContext(ReactReduxContext);
|
||||
const isWrappedWithReactFlowProvider = useMemo(() => contextValue?.store?.getState()?.reactFlowVersion, [
|
||||
contextValue,
|
||||
]);
|
||||
// let isWrapped = useRef<boolean>(true);
|
||||
|
||||
if (isWrappedWithReactFlowProvider) {
|
||||
// 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}</>;
|
||||
}
|
||||
// try {
|
||||
// useStoreApi();
|
||||
// } catch {
|
||||
// isWrapped.current = false;
|
||||
// }
|
||||
|
||||
return <Provider store={store}>{children}</Provider>;
|
||||
// if (isWrapped) {
|
||||
// // 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}</>;
|
||||
// }
|
||||
|
||||
return <Provider createStore={createStore}>{children}</Provider>;
|
||||
};
|
||||
|
||||
Wrapper.displayName = 'ReactFlowWrapper';
|
||||
|
||||
Reference in New Issue
Block a user