-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React 19 Old Error Back: Uncaught Error: Map container is already initialized. #1133
Comments
I tried to upgrade a big app from react 18.3.0 to latest react 19 rc (19.0.0-rc-915b914b3a-20240515) and I'm facing the same issue. Here is the simplest repro : https://codesandbox.io/p/sandbox/thirsty-zeh-34ddlm Thanks for your help. |
The issue seems to go away by disabling Strict Mode. |
workaround: const isInitialized = useRef(false);
useEffect(() => {
isInitialized.current = true;
return () => {
isInitialized.current = false;
};
}, []);
if (!isInitialized) return null; |
I encountered the same issue while testing this in the Next.js v15 RC. The Map container fails to mount, even with dynamic loading. A temporary workaround as you mentioned is to disable reactStrictMode for the entire app by setting { reactStrictMode: false } in next.config. Hopefully, we can find a proper solution soon. __ Not sure what is causing the component to initialize twice, I may need to break out of react-leaflet. |
Disabling React Strict Mode to fix react-leaflet for now: PaulLeCam/react-leaflet#1133
I am having this issue aswell |
Hello do we have a solution soon for this issue? Next.js 15 just released so I'd assume more people will run into this as well |
sorry for tagging you @PaulLeCam |
I'm using Next.js 15 with |
yes, it is working fine on |
Thanks you so much |
I am having this issue |
I am in the same case, but it does not work for me. I start the leaflet configuration with react-leaflet in local development and everything works, but when I do a |
I faced the same issue, but it was fixed after clearing the cache. Try deleting the .next dir |
I just tried it, but unfortunately it is still the same. I get the “Map container is already initialized.” error. |
I would also recommend deactivating the SSR for the map. Perhaps some of you have not yet done this and it may solve the import dynamic from 'next/dynamic';
const LazyMap = dynamic(() => import('./maps/map').then((mod) => mod.Map), { ssr: false }); |
My is dissabled.. I'll try with the rc1 version |
I was already using next/dynamic before. I have been changing versions and creating a new Next.js App Router project. I have managed to get it working both running
|
yeah
This temporarily work for me |
Solved my issue, thanks. |
This worked, Thanks |
Same here, went from React 18/Next 14 to React 18/Next 15, and this thing started to pop up. |
it's giving me peer dependency warning and errors with this |
works for me! |
Release candidate version of |
This works with Next.js 15.0.3, thank you! |
we have to wait for react-leaflet v5.0.0 to support React 19 (PaulLeCam/react-leaflet#1133)
Updating to react-leaflet version ^5.0.0 works for me now. |
This worked, thanks <3 |
Bug report in v4
Expected behavior
Working
Actual behavior
Well upgraded project to React 19 RC and the error popped up. Same as the past with ReactJs Upgrades
Not working getting error: Uncaught Error: Map container is already initialized.
Steps to reproduce
Upgrade project to React 19
The text was updated successfully, but these errors were encountered: