chore(zustand): upgrade to v4

This commit is contained in:
moklick
2022-08-06 16:57:32 +02:00
parent 6f6af23bf5
commit 753f442468
35 changed files with 126 additions and 55 deletions
@@ -1,10 +1,19 @@
import React, { FC, PropsWithChildren } from 'react';
import React, { FC, PropsWithChildren, useRef } from 'react';
import { StoreApi } from 'zustand';
import { Provider, createStore } from '../../store';
import { Provider } from '../../contexts/RFStoreContext';
import { createRFStore } from '../../store';
import { ReactFlowState } from '../../types';
const ReactFlowProvider: FC<PropsWithChildren<{}>> = ({ children }) => (
<Provider createStore={createStore}>{children}</Provider>
);
const ReactFlowProvider: FC<PropsWithChildren<{}>> = ({ children }) => {
const storeRef = useRef<StoreApi<ReactFlowState> | null>(null);
if (!storeRef.current) {
storeRef.current = createRFStore();
}
return <Provider value={storeRef.current}>{children}</Provider>;
};
ReactFlowProvider.displayName = 'ReactFlowProvider';