score:1

It seems that when you leave the page, the map element no longer exists but the event bound to it is still there!

According to React Component Life Cycle, we may wanna have a pair of the following in your component: componentDidMount and * componentWillUnmount*

constructor(props) {
  super(props);
  // ...
}

componentDidMount() {
  // bind the event
}

componentWillUnmount() {
  // unbind the event
}

render() {
  // ...
}

I don't know if you already have the above pair for initializing your map and its event.

However, there's still a lot of google map libraries out there, but not sure all of them handle all the events according to React Component Life Cycle well. There's another one below, and I also have simple guides based on it:

My guides:

Implementing google maps with react

How to incorporate <script> in React to add Google Maps instance

The library: https://github.com/istarkov/google-map-react

If this is still not what you want, feel free to post more code from yours for reference, then we may together find the best way


Related Query

More Query from same tag