[Feat] Deduplicate common code
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- react, typescript
- Área
- frontend
Línea de trabajo
Comienza comparando modules/react-mapbox/src/components/use-control.ts y modules/react-maplibre/src/components/use-control.ts; después, inspecciona las implementaciones correspondientes de NavigationControl. Determina qué funciones y componentes compartidos pueden trasladarse a un módulo interno común sin cambiar el comportamiento de ninguno de los dos módulos públicos; se considera terminado cuando tanto react-mapbox como react-maplibre consumen el código compartido sin duplicación.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 8.5k
- Forks
- 1.3k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de visgl/react-map-gl
-
DEFAULT_SETTINGS.maxBounds in @vis.gl/react-maplibre has 360° longitude span, triggers maplibre-gl-js#6148 crash via _updateSettings fallbackQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
visgl/react-map-gl#2591 · 2 comentarios ·
-
[Bug] Mapbox geocoder example crashes: "i is not a function"Posiblemente ocupada @yuiseki la tomó hace 20 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
visgl/react-map-gl#2628 ·
-
[Bug] Scroll zoom stops short of maxZoom in controlled mode with MapLibrePosiblemente ocupada @sviat-barbutsa la tomó hace 33 días. Abiertobug
Dificultad 3/5 Medio día Aptitud para principiantes 74/100
visgl/react-map-gl#2626 ·
-
[Bug] reuseMaps: Mapbox.reuse() infinite-loops (tab freeze) when the recycled map's container is the mount containerPosiblemente ocupada @mikeyfarina la tomó hace 82 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
visgl/react-map-gl#2613 ·
-
feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 42/100
visgl/react-map-gl#2603 · 1 reacción ·
Todos los issues de visgl/react-map-gl
Issues similares
-
accessibility area:ci ci-test level:low priority:high type:test
Dificultad 2/5 1-3 horas Aptitud para principiantes 71/100
skytuhua-org/Gen-V1#3132 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
drmrd/vernacular#1238 ·
Los mantenedores suelen responder en 1 día
-
question
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
enhancement migration-prioritized
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Hudson-Pufferfish/local-party-console#136 ·
Los mantenedores suelen responder en 1 día
-
priority:medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día