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
Source: stackoverflow.com
Related Query
- Cannot read property 'maps' of undefined - Google Maps - React JS
- Error adding Google Maps with react - TypeError: Cannot read property 'maps' of undefined
- Google maps in React without custom library: cannot read property setState of null
- React - uncaught TypeError: Cannot read property 'setState' of undefined
- react router v^4.0.0 Uncaught TypeError: Cannot read property 'location' of undefined
- React with ES7: Uncaught TypeError: Cannot read property 'state' of undefined
- Uncaught TypeError: Cannot read property 'state' of null in react
- Uncaught TypeError: Cannot read property 'toUpperCase' of undefined react state item
- React - Uncaught TypeError: Cannot read property 'func' of undefined
- Uncaught TypeError: Cannot read property 'value' of undefined in REACT JS
- React tutorial: Uncaught TypeError: Cannot read property 'data' of null
- Uncaught TypeError: Cannot read property 'map' of undefined with React
- Uncaught TypeError: Cannot read property 'state' of undefined - React
- React JS and Google Spreadsheets: Cannot Read Property '2' of Null
- React JS - Uncaught TypeError: Cannot read property 'bind' of undefined
- React Js Uncaught (in promise) TypeError: Cannot read property of undefined
- React v16: Uncaught TypeError: Cannot read property 'object' of undefined
- react js mapStateToProps triggers Uncaught TypeError: Cannot read property 'map' of undefined
- Uncaught TypeError: Cannot read property 'length' of undefined , using react and redux-form validation
- Error: Uncaught [TypeError: Cannot read property 'x' of undefined Jest react testing
- React Uncaught TypeError: cannot read property x of undefined
- React Uncaught TypeError: Cannot read property 'replace' of undefined
- React Testing Error: Uncaught [TypeError: Cannot read property 'map' of undefined]
- Uncaught TypeError: Cannot read property 'then' of undefined in React ajax Call?
- Uncaught TypeError: Cannot read property 'CSSTransitionGroup' of undefined, react addons
- Uncaught TypeError: Cannot read property 'history' of undefined !! React router
- React browserHistory.push giving Uncaught TypeError: Cannot read property 'push' of undefined
- React - Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
- Uncaught TypeError: Cannot read property 'map' of undefined - React js
- React Redux - Uncaught (in promise) TypeError: Cannot read property 'props' of undefined
More Query from same tag
- React JS inheritance
- Nested drag and drop with react dragula
- React componentDidMount fetch api
- Firebase Hosting Automatic Cache Busting with Bundle hash change in .js file /service-worker.js
- refactoring code from syncronous to asyncronous flow
- why is my site not redirecting to social sites but mydomain/facebook?
- React-router-dom v4 does not render the component
- Need to set up yup validation which is not required and works on only one condition
- Hash router works in production but browser router doesn't in react webpack app
- Make Div appear only when the page is scrolling
- Get an Icon with subtext and then a list on the same line?
- Where should I store my JWT in 2019 and is the localStorage really not secure?
- how to make an image fit to div
- How to test redux action by onClick with enzyme
- Can't resolve '@progress/kendo-react-treeview'
- react js - prevstate does not remember the previous state?
- Chart works uncorrectly chart.js
- Redirect to another screen on the second step of the form
- I have a list of object. I want to show 8 items in the first row. If length of list is more than 8 then add one show more button
- Apollo Subscriptions: Apollo Graphql is receiving updates on Playground but not on client
- React Component State Not Updating
- React Testing Library: How to test components that contain useLocation()?
- How to create input HOC components correctly?
- React-router-dom: Link cause the url to change but not the new component to load
- Error callback using echo-laravel and react
- How to trigger animations in a React app based on the scroll position
- Merge keys in JSON object to return an array of merged keys and the value with Javascript
- react router v4 programmatically change route
- Pass quoted variable to function in React
- React Rails: Objects are not valid as a react child