162 user not always seeing heatmap legend reset to city after mousing out of heatmap neighborhoods 1 - #167
Conversation
…reset-to-city-after-mousing-out-of-heatmap-neighborhoods-1
| setSelectedFeature(null); | ||
| }, 100); | ||
|
|
||
| setResetTimeoutId(newTimeoutId); |
There was a problem hiding this comment.
Introducing this new state variable actually has more significant side effects than first appears. Because this function is dependent upon the variable, every time the variable is updated with the setter, it's going to trigger a redraw of the component and, because the map depends on this function, a redraw of the map.
The result is that, when the mouse is over the map, the browser enters into effectively an infinite loop of redraws until the mouse leaves the map. This is not really an efficient way to have the app run. To confirm this, add a console.log into this function. You'll see it print out repeatedly non-stop when the mouse is over a map.
francisli
left a comment
There was a problem hiding this comment.
I'm not sure I want to accept this fix per the comment I left in the code. But, I don't have an idea yet of an alternative implementation...
modified onMouseOverZip function by setting a timeout to clear the selected feature after a short delay if the mouse moves out of the area