refactor(state): replace redux with zustand
This commit is contained in:
@@ -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 }]);
|
||||
|
||||
Reference in New Issue
Block a user