refactor(controls): dont import store but use actions
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { memo, ComponentType, CSSProperties } from 'react';
|
||||
import cx from 'classnames';
|
||||
|
||||
import store from '../../store';
|
||||
import { useStoreActions } from '../../store/hooks';
|
||||
import { ElementId, Edge, EdgeCompProps } from '../../types';
|
||||
|
||||
interface EdgeWrapperProps {
|
||||
@@ -38,6 +38,7 @@ export default (EdgeComponent: ComponentType<EdgeCompProps>) => {
|
||||
className,
|
||||
...rest
|
||||
}: EdgeWrapperProps) => {
|
||||
const setSelectedElements = useStoreActions((a) => a.setSelectedElements);
|
||||
const edgeClasses = cx('react-flow__edge', `react-flow__edge-${type}`, className, { selected, animated });
|
||||
const edgeGroupStyle: CSSProperties = {
|
||||
pointerEvents: isInteractive ? 'all' : 'none',
|
||||
@@ -47,7 +48,7 @@ export default (EdgeComponent: ComponentType<EdgeCompProps>) => {
|
||||
return;
|
||||
}
|
||||
|
||||
store.dispatch.setSelectedElements({ id, source, target });
|
||||
setSelectedElements({ id, source, target });
|
||||
|
||||
if (onClick) {
|
||||
onClick({ id, source, target, type });
|
||||
|
||||
Reference in New Issue
Block a user