Skip to content

Commit

Permalink
chore: remove lodash.flatten in favor of array.flat()
Browse files Browse the repository at this point in the history
  • Loading branch information
dornelasnelson committed Jan 2, 2024
1 parent 2486bea commit ac633fa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 40 deletions.
16 changes: 0 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@mapbox/geojson-rewind": "^0.5.2",
"@mapbox/geojsonhint": "^3.1.0",
"leaflet-path-drag": "^1.8.0-beta.3",
"lodash.flatten": "^4.4.0",
"react-undo-redo": "^3.0.0"
},
"devDependencies": {
Expand All @@ -66,7 +65,6 @@
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^29.4.0",
"@types/leaflet": "^1.9.1",
"@types/lodash.flatten": "^4.4.7",
"@types/node": "^18.14.2",
"@types/react": "^18.0.28",
"@types/react-leaflet": "^3.0.0",
Expand Down
43 changes: 21 additions & 22 deletions src/PolygonMap/PolygonMap.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import { LatLngTuple } from 'leaflet';
import flatten from 'lodash.flatten';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useMap } from 'react-leaflet';

import { ActionBar } from '../ActionBar/ActionBar';
import { Modal } from '../common/components/Modal';
import { MAP } from '../constants';
import { ExportPolygonForm } from '../conversion/ExportPolygonForm';
import { ImportPolygonForm } from '../conversion/ImportPolygonForm';
import { createLeafletLatLngBoundsFromCoordinates } from '../helpers';
import { Container, Map } from '../leaflet/Map';
import { TileLayer } from '../leaflet/TileLayer';
import { Coordinate, RectangleSelection } from '../types';
import { BoundaryPolygon } from './components/BoundaryPolygon';
import { ActivePolygon } from './components/ActivePolygon';
import { InactivePolygon } from './components/InactivePolygon';
import { PolygonPane } from './components/PolygonPane';
import { Polyline } from './components/Polyline';
import { SelectionRectangle } from './components/SelectionRectangle';
import { MapInner } from './components/MapInner';
import { LatLngTuple } from 'leaflet'
import { useCallback, useEffect, useRef, useState } from 'react'
import { useMap } from 'react-leaflet'

import { ActionBar } from '../ActionBar/ActionBar'
import { Modal } from '../common/components/Modal'
import { MAP } from '../constants'
import { ExportPolygonForm } from '../conversion/ExportPolygonForm'
import { ImportPolygonForm } from '../conversion/ImportPolygonForm'
import { createLeafletLatLngBoundsFromCoordinates } from '../helpers'
import { Container, Map } from '../leaflet/Map'
import { TileLayer } from '../leaflet/TileLayer'
import { Coordinate, RectangleSelection } from '../types'
import { ActivePolygon } from './components/ActivePolygon'
import { BoundaryPolygon } from './components/BoundaryPolygon'
import { InactivePolygon } from './components/InactivePolygon'
import { MapInner } from './components/MapInner'
import { PolygonPane } from './components/PolygonPane'
import { Polyline } from './components/Polyline'
import { SelectionRectangle } from './components/SelectionRectangle'

export interface PolygonMapProps {
activePolygon: Coordinate[];
Expand Down Expand Up @@ -103,7 +102,7 @@ export const PolygonMap = ({

const reframeOnPolygon = (polygonCoordinates: Coordinate[] | Coordinate[][]) => {
if (map.current && !!polygonCoordinates.length) {
const bounds = createLeafletLatLngBoundsFromCoordinates(flatten(polygonCoordinates));
const bounds = createLeafletLatLngBoundsFromCoordinates(polygonCoordinates.flat());

map.current.fitBounds(bounds);
}
Expand Down

0 comments on commit ac633fa

Please sign in to comment.