When trying to remove and event handler use Map.off this is not working as expected
Expected behaviour
A click event listener should be removed
/mapContext.off('click',layer_id, function);
You need to get the map instance using the map context as described in the documentation. That's what you can call this method on.
The context is a React way of providing this instance wherever you need it, without things like render props. The context is NOT the map instance. If the docs are unclear, please open a separate issue.
Adding the event listeners seems to work, I am using the map instance that is provided in the MapContext.Consumer, to add the event listeners to layers, and they work as expected, however removing them doesn't seem to work?
any further help with this would be greatly appreciated
That sounds like an issue with mapbox-gl-js instead of react-mapbox-gl then... This library isn't doing anything to alter the calls to the map instance.
Thanks for the help, I appreciate it.
Any workaround for map.off in React?
The same here, adding event works perfectly but turn if off doenst affect at all, not even errors.
That sounds like an issue with mapbox-gl-js instead of react-mapbox-gl then... This library isn't doing anything to alter the calls to the map instance.