feat(onError): add onError prop #2772
This commit is contained in:
@@ -5,7 +5,7 @@ import { shallow } from 'zustand/shallow';
|
||||
import { useStore, useStoreApi } from '../../hooks/useStore';
|
||||
import { useNodeId } from '../../contexts/NodeIdContext';
|
||||
import { handlePointerDown } from './handler';
|
||||
import { devWarn, getHostForElement, isMouseEvent } from '../../utils';
|
||||
import { getHostForElement, isMouseEvent } from '../../utils';
|
||||
import { addEdge } from '../../utils/graph';
|
||||
import { Position } from '../../types';
|
||||
import type { HandleProps, Connection, ReactFlowState } from '../../types';
|
||||
@@ -42,7 +42,10 @@ const Handle = forwardRef<HTMLDivElement, HandleComponentProps>(
|
||||
const nodeId = useNodeId();
|
||||
|
||||
if (!nodeId) {
|
||||
devWarn('Handle: No node id found. Make sure to only use a Handle inside a custom Node.');
|
||||
store
|
||||
.getState()
|
||||
.onError?.('010', 'Handle: No node id found. Make sure to only use a Handle inside a custom Node.');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ export function isValidHandle(
|
||||
const isValid =
|
||||
connectionMode === ConnectionMode.Strict
|
||||
? (isTarget && handleIsSource) || (!isTarget && handleIsTarget)
|
||||
: handleNodeId !== handle.nodeId || handleId !== handle.id;
|
||||
: handleNodeId !== fromNodeId || handleId !== fromHandleId;
|
||||
|
||||
if (isValid) {
|
||||
result.isValid = isValidConnection(connection);
|
||||
|
||||
Reference in New Issue
Block a user