Our app does not work in React StrictMode
Opened this issue · 1 comments
see: 40238bf
For example when StrictMode is enabled the maps context menu no longer works and the positioning of the custom model editor is broken.
I think the reason the context menu does not open in strict mode is that the context menu listener is removed here:
but it is only added via the map.once('target:change')
callback here:
Since StrictMode runs the useEffect multiple times the listener is removed but not added again. And the reason we add the listener in this strange way, is that the useEffect is called for the map
before it has a target element. Maybe we should do this another way, but currently I don't really know how. The target element is attached here at the moment:
graphhopper-maps/src/map/MapComponent.tsx
Line 14 in d376677