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
+4 -7
View File
@@ -1,5 +1,4 @@
import create from 'zustand';
import createContext from 'zustand/context';
import { createStore } from 'zustand';
import { clampPosition, getDimensions, internalsSymbol } from '../utils';
import { applyNodeChanges } from '../utils/changes';
@@ -21,10 +20,8 @@ import { createSelectionChange, getSelectionChanges } from '../utils/changes';
import { createNodeInternals, fitView, updateNodesAndEdgesSelections } from './utils';
import initialState from './initialState';
const { Provider, useStore, useStoreApi } = createContext<ReactFlowState>();
const createStore = () =>
create<ReactFlowState>((set, get) => ({
const createRFStore = () =>
createStore<ReactFlowState>((set, get) => ({
...initialState,
setNodes: (nodes: Node[]) => {
set({ nodeInternals: createNodeInternals(nodes, get().nodeInternals) });
@@ -236,4 +233,4 @@ const createStore = () =>
reset: () => set({ ...initialState }),
}));
export { Provider, useStore, createStore, useStoreApi };
export { createRFStore };