mapcomponents / react-map-components-maplibre

A react component framework for declarative GIS application development.
MIT License
116 stars 18 forks source link

Bug: Event handlers passed to `MlGeoJsonLayer` are not updated #179

Closed andrejilderda closed 3 weeks ago

andrejilderda commented 3 weeks ago

First, thanks for the work on this library!

I'm running into the issue that event handlers passed to MlGeoJsonLayer (and possibly other layers) are not properly updated. This occurs when for example an onClick-handler is passed to a <MlGeoJsonLayer> which contains a stateful value.

Version

@mapcomponents/react-maplibre 1.0.5 (latest)

Reproduction link:

https://codesandbox.io/p/sandbox/base-template-forked-ppjjjg?file=%2Fsrc%2FApp.js%3A275%2C13

Steps To Reproduce

  1. Open the provided CodeSandbox link.
  2. Open the browser console to observe logs.
  3. Click on the red line (route) on the map.

The current behavior

When clicking on the route (red line), the state.zoom value logged in the console remains 4 and does not reflect the updated zoom level.

The expected behavior

When clicking on the route, the logged state.zoom value should reflect the updated zoom level (incremented by 1 from the previous value).

Additional notes:

If you need more information, feel free to reach out!


EDIT: Removed comment regarding useEffect firing twice (which is intended React behavior).

andrejilderda commented 3 weeks ago

Edit: not relevant anymore.

cioddi commented 3 weeks ago

Hi @andrejilderda, thank you for raising the issue. We have been aware of this issue and it is fixed in the latest release 1.0.6 that was just released a few minutes ago.

andrejilderda commented 3 weeks ago

Awesome, thanks a lot!