refactor(state): replace redux with zustand

This commit is contained in:
moklick
2021-10-13 12:54:01 +02:00
parent e01249a87c
commit ee0d29029a
38 changed files with 786 additions and 896 deletions
+6 -4
View File
@@ -1,13 +1,15 @@
import { useCallback } from 'react';
import { useStoreActions } from '../store/hooks';
import { ElementId, UpdateNodeInternals } from '../types';
import { useStore } from '../store';
import { ElementId, UpdateNodeInternals, ReactFlowState } from '../types';
const updateNodeDimsSelector = (state: ReactFlowState) => state.updateNodeDimensions;
function useUpdateNodeInternals(): UpdateNodeInternals {
const updateNodeDimensions = useStoreActions((actions) => actions.updateNodeDimensions);
const updateNodeDimensions = useStore(updateNodeDimsSelector);
return useCallback<UpdateNodeInternals>((id: ElementId) => {
const nodeElement = document.querySelector(`.react-flow__node[data-id="${id}"]`);
const nodeElement = document.querySelector(`.react-flow__node[data-id="${id}"]`) as HTMLDivElement;
if (nodeElement) {
updateNodeDimensions([{ id, nodeElement, forceUpdate: true }]);