question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onMouseLeave in Layer component not firing

See original GitHub issue

Hi there, the onMouseLeave callback on the Layer component is not working. Do you have a fix for that?

package.json

"mapbox-gl": "^1.0.0",
"react-mapbox-gl": "^4.2.3"

Component

import ReactMapboxGl, { Layer, Feature } from "react-mapbox-gl"

const mapShape = ...

let Map = false

// Gatsby specific config
if (typeof window !== `undefined`) {
  Map = ReactMapboxGl({
    accessToken: "..."
  })
}

const Mapbox = () => {

return (
 <>
   {Map &&
    <Map style="mapbox://styles/...">
      <Layer
         paint={{
            "fill-color": "#000",
            "fill-opacity": 1,
            "fill-outline-color": "#fff"
         }}
         onMouseEnter={() => console.log('I'm working fine')}
         onMouseLeave={() => console.log('I'm useless')}
       >
          <Feature coordinates={mapShape} />
      </Layer>
    </Map>
   }
  </>
 )
}

Let me know if you need more information.

Cheers Robin

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

2reactions
rsurgiewiczcommented, Mar 11, 2022

Confirmed in the latest one: 7.0.8 Actually it is not working for any onMouse… events for me

2reactions
AdriSolidcommented, Jan 14, 2020

Getting same behavior with the following versions: "mapbox-gl": "^1.6.1" "react-mapbox-gl": "^4.8.2"

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - mouseleave event not firing in gatsby component
I'm trying to create a drop down menu component and the mouseleave is not firing on the div. If i use document.addEventListerner('click' ...
Read more >
onmouseleave does not fire if you have mutiple elements react
We see that the mouseleave event is always fired before the mouse enter event. The same is true if I have a react...
Read more >
Element: mouseleave event - Web APIs | MDN
The mouseleave event is fired at an Element when the cursor of a pointing device (usually a mouse) is moved out of it....
Read more >
mouseover event is not firing on element on which written
I found the solution. I used mouseenter event instead of mouseover and it worked.
Read more >
UUserWidget::OnMouseLeave - Unreal Engine Documentation
const FPointerEvent & MouseEvent ). Remarks. The system will use this event to notify a widget that the cursor has left it. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found