From 7e0e4c061533406dda1a070705d0ed307a86a29a Mon Sep 17 00:00:00 2001 From: Carl von Buelow Date: Tue, 14 Mar 2023 19:42:39 -0400 Subject: [PATCH] Only import required lodash methods to reduce bundle size --- src/Xarrow/useXarrowProps.ts | 4 ++-- src/Xarrow/utils/GetPosition.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Xarrow/useXarrowProps.ts b/src/Xarrow/useXarrowProps.ts index 6300445b..632a810c 100644 --- a/src/Xarrow/useXarrowProps.ts +++ b/src/Xarrow/useXarrowProps.ts @@ -10,7 +10,7 @@ import { xarrowPropsType, } from '../types'; import { getElementByPropGiven, getElemPos, xStr2absRelative } from './utils'; -import _ from 'lodash'; +import isEqual from 'lodash/isEqual'; import { arrowShapes, cAnchorEdge, cArrowShapes } from '../constants'; import { anchorEdgeType, dimensionType } from '../privateTypes'; @@ -293,7 +293,7 @@ const initialValVars = { // const parseAllProps = () => parseGivenProps(defaultProps, initialParsedProps); function deepCompareEquals(a, b) { - return _.isEqual(a, b); + return isEqual(a, b); } function useDeepCompareMemoize(value) { diff --git a/src/Xarrow/utils/GetPosition.tsx b/src/Xarrow/utils/GetPosition.tsx index c141e9a2..eb5423e0 100644 --- a/src/Xarrow/utils/GetPosition.tsx +++ b/src/Xarrow/utils/GetPosition.tsx @@ -2,7 +2,7 @@ import { useXarrowPropsResType } from '../useXarrowProps'; import React from 'react'; import { calcAnchors } from '../anchors'; import { getShortestLine, getSvgPos } from './index'; -import _ from 'lodash'; +import pick from 'lodash/pick'; import { cPaths } from '../../constants'; import { buzzierMinSols, bzFunction } from './buzzier'; @@ -46,8 +46,8 @@ export const getPosition = (xProps: useXarrowPropsResType, mainRef: React.Mutabl let startAnchorPosition = chosenStart.anchor.position, endAnchorPosition = chosenEnd.anchor.position; - let startPoint = _.pick(chosenStart, ['x', 'y']), - endPoint = _.pick(chosenEnd, ['x', 'y']); + let startPoint = pick(chosenStart, ['x', 'y']), + endPoint = pick(chosenEnd, ['x', 'y']); let mainDivPos = getSvgPos(svgRef); let cx0 = Math.min(startPoint.x, endPoint.x) - mainDivPos.x;