[Feat] Deduplicate common code
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Bắt đầu bằng cách so sánh modules/react-mapbox/src/components/use-control.ts và modules/react-maplibre/src/components/use-control.ts, sau đó kiểm tra các triển khai NavigationControl tương ứng. Xác định những hàm và component dùng chung nào có thể được chuyển vào một module chung nội bộ mà không thay đổi hành vi của một trong hai module công khai; hoàn thành có nghĩa là cả react-mapbox và react-maplibre đều sử dụng code dùng chung mà không bị trùng lặp.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Target Use Case
I'm working on a library for a project that show a Mapbox or MapLibre map depending of a parameter. Since the update to mapbox-gl>=3.5.0 and react-map-gl 8.x, the duplication of functions and components pose us problems.
Here an example of what we're forced to do:
import { MapboxOverlay, type MapboxOverlayProps } from '@deck.gl/mapbox';
import {
Map as MapGL,
type MapProps as MapGlProps,
type MapRef as MapGlRef,
NavigationControl as NavigationControlGl,
useControl as useControlGl,
} from 'react-map-gl/mapbox';
import {
Map as MapLibre,
type MapProps as MapLibreProps,
type MapRef as MapLibreRef,
NavigationControl as NavigationControlLibre,
useControl as useControlLibre,
} from 'react-map-gl/maplibre';
// ...
type DeckGLOverlayProps = MapboxOverlayProps & { typeMap: TypeMap };
const DeckGLOverlay = forwardRef<MapboxOverlay, DeckGLOverlayProps>(({ typeMap, ...props }, ref) => {
let overlay: MapboxOverlay;
/* We can ignore ESlint rule react-hooks/rules-of-hooks here because useControl implementation is the same in the two cases
* https://github.com/visgl/react-map-gl/blob/8.0-release/modules/react-mapbox/src/components/use-control.ts
* https://github.com/visgl/react-map-gl/blob/8.0-release/modules/react-maplibre/src/components/use-control.ts
*/
if (typeMap === TypeMap.GL) {
overlay = useControlGl(() => new MapboxOverlay(props)); // eslint-disable-line react-hooks/rules-of-hooks
} else {
// @ts-expect-error: MapboxOverlay extends mapbox-gl.IControl while useControl ask for maplibre-gl.IControl ...
overlay = useControlLibre(() => new MapboxOverlay(props)); // eslint-disable-line react-hooks/rules-of-hooks
}
overlay.setProps(props);
return null;
});
// ...
return (
<Map>
<DeckGLOverlay typeMap={props.mapLibrary === MAPBOX ? TypeMap.GL : TypeMap.Libre} /*...*/ />
{props.mapLibrary === MAPBOX ? <NavigationControlGl /> : <NavigationControlLibre />}
{/*...*/}
</Map>
);
}
Proposal
After looking quickly in the sources, it seems possible for some functions and components to be moved in an internal module "common".
It is possible to de-duplicate some code like useControl and NavigationControl and move them in an internal module "common".
Then "react-mapbox" and "react-maplibre" modules would have as dependency this common module as a result.
- Ngôn ngữ chính
- TypeScript
- Star
- 8.5k
- Fork
- 1.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của visgl/react-map-gl
-
DEFAULT_SETTINGS.maxBounds in @vis.gl/react-maplibre has 360° longitude span, triggers maplibre-gl-js#6148 crash via _updateSettings fallbackCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
visgl/react-map-gl#2591 · 2 bình luận ·
-
[Bug] Mapbox geocoder example crashes: "i is not a function"Có thể đã có người làm @yuiseki đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
visgl/react-map-gl#2628 ·
-
[Bug] Scroll zoom stops short of maxZoom in controlled mode with MapLibreCó thể đã có người làm @sviat-barbutsa đã nhận 33 ngày trước. Đang mởbug
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 74/100
visgl/react-map-gl#2626 ·
-
[Bug] reuseMaps: Mapbox.reuse() infinite-loops (tab freeze) when the recycled map's container is the mount containerCó thể đã có người làm @mikeyfarina đã nhận 82 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
visgl/react-map-gl#2613 ·
-
feature
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
visgl/react-map-gl#2603 · 1 reaction ·
Tất cả issue của visgl/react-map-gl
Issue tương tự
-
accessibility area:ci ci-test level:low priority:high type:test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 71/100
skytuhua-org/Gen-V1#3132 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
drmrd/vernacular#1238 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
question
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
enhancement migration-prioritized
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Hudson-Pufferfish/local-party-console#136 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
priority:medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày