vadzim/use-leaflet

The hook won't update

Closed this issue · 7 comments

Hi, great hooks which make interaction with the leaflet object much easier.
When I implement them (like in the provided tests), only the initial value is returned. No updated values for center, zoom or bounds are triggered.

Is this unsupported?

Hi.
It should work for sure and it seems it worked in my own projects.
Also there should be tests for that.
I'll double check this and return with exact info.

Hi, @hoetmaaiers
I've made a simple test on codesandbox and that hook works for me.
See https://codesandbox.io/embed/use-leaflet-jbftf

Could you please provide me a code which does not work for you?

Please, reopen this issue when you provide more info about it.
I'm closing it for a while.

@hoetmaaiers btw, do you use the latest version of use-leaflet?

Hi Vadzim, I managed to find out why it was not working. I steped away from use-leaflet to ensure the hooks way would not be causing any issues. The real problem though was that I had 2 leaflet versions and therefor packages running. This means 2 leaflet instances and therefore no shared context between these instances.

Thank you for the great library and I will continue to use it!

@hoetmaaiers Many thanks for your feedback!

PS I can't imagine how I would catch an issue with two leaflet instances...

With pleasure!

For the record, I had two instances, because of a component library package (we maintain for ourselves) uses Leaflet and the importing app also uses Leaflet. This was solved by defining leaflet and others as peerDependencies in the component library package.