rc-here-maps
rc-here-maps copied to clipboard
Preventing loop in react component
Hi!
I am currently using your library in one of my projects to allow user to draw routes that he chooses from side panel. If user clicks too quick on another route to be drawn there will be multiple routes drawn, because old ones are still awaiting response from HereAPI and are not being properly unmounted. So this creates hot mess.
My solution was to show overlay with loading spinner until routes is drawn with onPathCreated
, but to do this I need to update state like: this.setState({loadingOverlay: false})
which triggers rerender and my route is drawn again and triggers setState
again... and we are in the loop.
So naturally I thought about shouldComponentUpdate
, but this prevents component from using loadingOverlay: false
so overlay is still there even after route has finished loading.
Maybe my problem is trivial and I can't see it, but please take a moment for this issue because I've tried for a week now with no results.