refactor(store): use store.setState directly instead of actions

This commit is contained in:
moklick
2021-12-11 05:22:41 +01:00
parent 1a2ac5aa3e
commit 895e0bc524
14 changed files with 110 additions and 245 deletions
+3 -6
View File
@@ -1,13 +1,10 @@
import { useEffect, MutableRefObject } from 'react';
import { useStore } from '../store';
import { useStoreApi } from '../store';
import { getDimensions } from '../utils';
import { ReactFlowState } from '../types';
const updateSizeSelector = (state: ReactFlowState) => state.updateSize;
function useResizeHandler(rendererNode: MutableRefObject<HTMLDivElement | null>): void {
const updateSize = useStore(updateSizeSelector);
const store = useStoreApi();
useEffect(() => {
let resizeObserver: ResizeObserver;
@@ -23,7 +20,7 @@ function useResizeHandler(rendererNode: MutableRefObject<HTMLDivElement | null>)
console.warn('The React Flow parent container needs a width and a height to render the graph.');
}
updateSize(size);
store.setState({ width: size.width || 500, height: size.height || 500 });
};
updateDimensions();