JustFly1984 / react-google-maps-api

React Google Maps API
MIT License
1.78k stars 437 forks source link

MarkerClustererF isn't working properly in NextJS in Strict Mode #3150

Open bartsam opened 1 year ago

bartsam commented 1 year ago

The render of MarkerClustererF isn't working properly with NextJs in strict mode. Sometime on rerender it appear until another render.

I made an exemple on codesandbox with a basic config : https://codesandbox.io/p/sandbox/serene-liskov-nu89s8?selection=%5B%7B%22endColumn%2[…]rcquy%2522%252C%2522isMinimized%2522%253Afalse%257D%255D%257D

Have you an idea of the problem ?

Tillytaly commented 1 year ago

Same issue here, updated to the newest api version but MarkerClustererF is still not working in strict mode. Also nextJs app.

Hilver commented 1 year ago

+1

IsaacHatilima commented 1 year ago

Same issue. if I use MarkerClusterer I can see the Markers with MarkerF but the are not clustering, but if I use MarkerClustererF the Markers disappear.

klarstrup commented 1 year ago

A lot of things are broken with this module in strictmode, see also: https://github.com/JustFly1984/react-google-maps-api/issues/3095

andrikash commented 1 year ago

The same here, sometimes, not always clustering isn't working at all or isn't working properly. Properties: next.js, strict mode dynamic data for markers

nathannye commented 1 year ago

Running into the same issue with the same code as OP in Next 13 & React 18 Strict. The Clusterer class can be accessed in the callback for onLoad, it has the full array of markers to cluster but will not display them.

welschmoor commented 1 year ago

reactStrictMode: false

Or you can also turn off strict mode for some pages (or rather turn it on where you want it)

https://nextjs.org/docs/api-reference/next.config.js/react-strict-mode https://beta.reactjs.org/reference/react/StrictMode#enabling-strict-mode-for-a-part-of-the-app

klarstrup commented 1 year ago

reactStrictMode: false

https://nextjs.org/docs/api-reference/next.config.js/react-strict-mode

Obviously OP knows how to disable strict mode they had to enable it to produce this problem in the first place

It not working in strict mode means it might break fully in future react versions and is a sign of underlying problems with the implementation

Plus this also applies to react strict mode outside of Next.js

gundogduyakici commented 11 months ago

Same issue +1