refactor(dev-warnings): cleanup
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useMemo } from 'react';
|
||||
import { MarkerType, EdgeMarker } from '../../types';
|
||||
import { devWarn } from '../../utils';
|
||||
|
||||
type SymbolProps = Omit<EdgeMarker, 'type'>;
|
||||
|
||||
@@ -39,9 +40,7 @@ export function useMarkerSymbol(type: MarkerType) {
|
||||
const symbolExists = Object.prototype.hasOwnProperty.call(MarkerSymbols, type);
|
||||
|
||||
if (!symbolExists) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.warn(`[React Flow]: Marker type "${type}" doesn't exist. Help: https://reactflow.dev/error#900`);
|
||||
}
|
||||
devWarn(`Marker type "${type}" doesn't exist. Help: https://reactflow.dev/error#900`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { getEdgePositions, getHandle, getNodeData } from './utils';
|
||||
|
||||
import { Position, Edge, ConnectionMode, ReactFlowState } from '../../types';
|
||||
import { GraphViewProps } from '../GraphView';
|
||||
import { devWarn } from '../../utils';
|
||||
|
||||
interface EdgeRendererProps
|
||||
extends Pick<
|
||||
@@ -111,13 +112,12 @@ const EdgeRenderer = (props: EdgeRendererProps) => {
|
||||
const targetPosition = targetHandle?.position || Position.Top;
|
||||
|
||||
if (!sourceHandle || !targetHandle) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
const handleType = !sourceHandle ? 'source' : 'target';
|
||||
const handleId = !sourceHandle ? edge.sourceHandle : edge.targetHandle;
|
||||
console.warn(
|
||||
`[React Flow]: Couldn't create edge for ${handleType} handle id: ${handleId}; edge id: ${edge.id}. Help: https://reactflow.dev/error#800`
|
||||
);
|
||||
}
|
||||
devWarn(
|
||||
`Couldn't create edge for ${!sourceHandle ? 'source' : 'target'} handle id: ${
|
||||
!sourceHandle ? edge.sourceHandle : edge.targetHandle
|
||||
}; edge id: ${edge.id}. Help: https://reactflow.dev/error#800`
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import shallow from 'zustand/shallow';
|
||||
|
||||
import useVisibleNodes from '../../hooks/useVisibleNodes';
|
||||
import { useStore } from '../../hooks/useStore';
|
||||
import { internalsSymbol } from '../../utils';
|
||||
import { devWarn, internalsSymbol } from '../../utils';
|
||||
import { containerStyle } from '../../styles';
|
||||
import { GraphViewProps } from '../GraphView';
|
||||
import { Position, ReactFlowState, WrapNodeProps } from '../../types';
|
||||
@@ -70,11 +70,9 @@ const NodeRenderer = (props: NodeRendererProps) => {
|
||||
let nodeType = node.type || 'default';
|
||||
|
||||
if (!props.nodeTypes[nodeType]) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.warn(
|
||||
`[React Flow]: Node type "${nodeType}" not found. Using fallback type "default". Help: https://reactflow.dev/error#300`
|
||||
);
|
||||
}
|
||||
devWarn(
|
||||
`Node type "${nodeType}" not found. Using fallback type "default". Help: https://reactflow.dev/error#300`
|
||||
);
|
||||
|
||||
nodeType = 'default';
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import OutputNode from '../../components/Nodes/OutputNode';
|
||||
import GroupNode from '../../components/Nodes/GroupNode';
|
||||
import wrapNode from '../../components/Nodes/wrapNode';
|
||||
import { NodeTypes, NodeProps, NodeTypesWrapped, NodeOrigin, XYPosition } from '../../types';
|
||||
import { devWarn } from '../../utils';
|
||||
|
||||
export type CreateNodeTypes = (nodeTypes: NodeTypes) => NodeTypesWrapped;
|
||||
|
||||
@@ -50,7 +51,7 @@ export const getPositionWithOrigin = ({
|
||||
}
|
||||
|
||||
if (origin[0] < 0 || origin[1] < 0 || origin[0] > 1 || origin[1] > 1) {
|
||||
console.warn('[ReactFlow]: nodeOrigin must be between 0 and 1');
|
||||
devWarn('nodeOrigin must be between 0 and 1');
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useMemo, useRef } from 'react';
|
||||
import shallow from 'zustand/shallow';
|
||||
|
||||
import { EdgeTypes, EdgeTypesWrapped, NodeTypes, NodeTypesWrapped } from '../../types';
|
||||
import { devWarn } from '../../utils';
|
||||
import { CreateEdgeTypes } from '../EdgeRenderer/utils';
|
||||
import { CreateNodeTypes } from '../NodeRenderer/utils';
|
||||
|
||||
@@ -15,8 +16,8 @@ export function useNodeOrEdgeTypes(nodeOrEdgeTypes: any, createTypes: any): any
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
const typeKeys = Object.keys(nodeOrEdgeTypes);
|
||||
if (shallow(typesKeysRef.current, typeKeys)) {
|
||||
console.warn(
|
||||
"[React Flow]: It looks like you have created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them. Help: https://reactflow.dev/error#200"
|
||||
devWarn(
|
||||
"It looks like you have created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them. Help: https://reactflow.dev/error#200"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user