refactor(dev-warnings): cleanup

This commit is contained in:
moklick
2022-08-17 11:55:37 +02:00
parent ab14be02f4
commit 86ea34b470
9 changed files with 39 additions and 46 deletions
+3 -4
View File
@@ -1,7 +1,7 @@
import { RefObject } from 'react';
import { CoordinateExtent, Node, NodeDragItem, NodeInternals, XYPosition } from '../../types';
import { clampPosition } from '../../utils';
import { clampPosition, devWarn } from '../../utils';
export function isParentSelected(node: Node, nodeInternals: NodeInternals): boolean {
if (!node.parentNode) {
@@ -78,9 +78,8 @@ export function calcNextPosition(
]
: currentExtent;
} else {
if (process.env.NODE_ENV === 'development') {
console.warn('[React Flow]: Only child nodes can use a parent extent. Help: https://reactflow.dev/error#500');
}
devWarn('Only child nodes can use a parent extent. Help: https://reactflow.dev/error#500');
currentExtent = nodeExtent;
}
} else if (node.extent && node.parentNode) {
+5 -7
View File
@@ -1,7 +1,7 @@
import { useEffect, MutableRefObject } from 'react';
import { useStoreApi } from '../hooks/useStore';
import { getDimensions } from '../utils';
import { devWarn, getDimensions } from '../utils';
function useResizeHandler(rendererNode: MutableRefObject<HTMLDivElement | null>): void {
const store = useStoreApi();
@@ -16,12 +16,10 @@ function useResizeHandler(rendererNode: MutableRefObject<HTMLDivElement | null>)
const size = getDimensions(rendererNode.current);
if (process.env.NODE_ENV === 'development') {
if (size.height === 0 || size.width === 0) {
console.warn(
'[React Flow]: The React Flow parent container needs a width and a height to render the graph. Help: https://reactflow.dev/error#400'
);
}
if (size.height === 0 || size.width === 0) {
devWarn(
'The React Flow parent container needs a width and a height to render the graph. Help: https://reactflow.dev/error#400'
);
}
store.setState({ width: size.width || 500, height: size.height || 500 });