Issues with useControl when upgrading to nextjs 14.2
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- nextjs, react, typescript
Direzione di ricerca
Inizia dal callback useControl in draw-control.tsx e dal useEffect che chiama draw.getAll(); confronta il comportamento con Next 14.1 e 14.2 usando la configurazione Mapbox Draw riportata. Una riproduzione o un test utile dovrebbe stabilire perché getAll non è disponibile dopo il caricamento della mappa, dove done significa che è possibile accedere in modo affidabile ai disegni correnti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
I'm using an implementation that can be summed up as the following
<Map
initialViewState={initialViewState}
style={{ width: '100%', height: '100%' }}
mapStyle="mapbox://styles/mapbox/satellite-streets-v12"
>
<DrawControl
position="top-left"
onCreate={onUpdate}
onUpdate={onUpdate}
onDelete={onDelete}
/>
</Map>
Where DrawControl looks something like...
import MapboxDraw from '@mapbox/mapbox-gl-draw';
import { useControl } from 'react-map-gl';
export default function DrawControl({
onCreate = () => {},
onUpdate = () => {},
onDelete = () => {},
...props
}: DrawControlProps) {
const [draw, setDraw] = useState<MapboxDraw | null>(null);
useControl<MapboxDraw>(
() => {
const drawInstance = new MapboxDraw(props);
setDraw(drawInstance);
return drawInstance;
},
({ map }) => {
map.on('draw.create', onCreate);
map.on('draw.update', onUpdate);
map.on('draw.delete', onDelete);
},
({ map }) => {
map.off('draw.create', onCreate);
map.off('draw.update', onUpdate);
map.off('draw.delete', onDelete);
},
{
position: props.position,
}
);
useEffect(() => {
if (!draw || !mapReady) return;
const currentDrawings = draw.getAll();
}, [draw, someOtherVariableWeTrack]
We haven't had any issues with this implementation until upgrading to next 14.2. I've downgraded back to next 14.1 and confirmed that the issue is selective to next 14.2 for reasons I'm still trying to understand. The error I get is that draw.getAll() is undefined. Upon debugging, I can see that draw is indeed defined, along with some non-function attributes, but all the functions yield the same undefined error.
I have confirmed that this behavior happens even after the map is definitively loaded. I now have high confidence the issue is with the way I am storing drawInstance. From other posts online, it seems like this issue happens when the map is not yet loaded. However, I can confirm that the map is loaded and the draw control is present -- I can draw polygons on the map with no issues, but whenever I hit this useEffect, I always get the error, even once the map is loaded and I can confirm the ability to draw.
This is what leads me to believe it is something related to the way useControl is working, or at the very least is something related to the way that we're referencing the drawInstance.
Expected Behavior
In next 14.1, this works as expected. The expected behavior is to have access to the drawings that are currently on the map.
Steps to Reproduce
Can provide codesandbox if the description is not enough to understand the issue. Please let me know.
Environment
- Framework version: [email protected]
- Map library: [email protected] (tested with [email protected] with same issue)
- Next: 14.2 (all patch versions)
- mapboxdraw: @mapbox/[email protected]
- Browser: [email protected]
- OS: OSX 14.3.1
Logs
TypeError: Cannot read properties of undefined (reading 'getAll')
at e.getAll (mapbox-gl-draw.js:1:77757)
at eval (draw-control.tsx:50:34)
at commitHookEffectListMount (react-dom.development.js:21102:1)
at commitHookPassiveMountEffects (react-dom.development.js:23154:1)
at commitPassiveMountOnFiber (react-dom.development.js:23259:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23334:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23370:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
at commitPassiveMountOnFiber (react-dom.development.js:23256:1)
at recursivelyTraversePassiveMountEffects (react-dom.development.js:23237:1)
- Lingua principale
- TypeScript
- Stelle
- 8.5k
- Fork
- 1.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di visgl/react-map-gl
-
DEFAULT_SETTINGS.maxBounds in @vis.gl/react-maplibre has 360° longitude span, triggers maplibre-gl-js#6148 crash via _updateSettings fallbackForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
visgl/react-map-gl#2591 · 2 commenti ·
-
[Bug] Mapbox geocoder example crashes: "i is not a function"Forse già presa @yuiseki l’ha presa 20 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
visgl/react-map-gl#2628 ·
-
[Bug] Scroll zoom stops short of maxZoom in controlled mode with MapLibreForse già presa @sviat-barbutsa l’ha presa 33 giorni fa. Apertabug
Difficoltà 3/5 Mezza giornata Idoneità per principianti 74/100
visgl/react-map-gl#2626 ·
-
[Bug] reuseMaps: Mapbox.reuse() infinite-loops (tab freeze) when the recycled map's container is the mount containerForse già presa @mikeyfarina l’ha presa 82 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
visgl/react-map-gl#2613 ·
-
feature
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
visgl/react-map-gl#2603 · 1 reazione ·
Tutte le issue di visgl/react-map-gl
Issue simili
-
accessibility area:ci ci-test level:low priority:high type:test
Difficoltà 2/5 1-3 ore Idoneità per principianti 71/100
skytuhua-org/Gen-V1#3132 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
drmrd/vernacular#1238 ·
I maintainer di solito rispondono entro 1 giorno
-
question
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
enhancement migration-prioritized
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Hudson-Pufferfish/local-party-console#136 ·
I maintainer di solito rispondono entro 1 giorno
-
priority:medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno