Projection Change Leaves Old Projection Visible in Dev Mode (Next.js v14)
Framework: Next.js v14
I'm experiencing an issue with one of my maps in a React project using Mapbox GL JS. When I change the map's projection in development mode, the new projection is applied, but the previous projection remain visible in the background. However, after building the project, and running the build the problem disappears.
Has anyone encountered this behavior or have suggestions on how to diagnose and fix the issue in development mode?
Hey, @TheodoreRed! Thank you for the report!
Could you provide a minimal example of what you see? What library do you use for wrapping Mapbox GL JS in React? It seems to me that it was caused not by GL JS, but by your setup logic or environment. I can only guess that it might be related to something like double rerendering of <StrictMode> as an example
Hey @underoot I was able to resolve the double initialization in Strict Mode issue. Here's the snippet that worked for me:
const initializedRef = useRef(false);
useEffect(() => {
if (initializedRef.current) return;
initializedRef.current = true;
// Initialize map
}, []);