You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, we are currently spiking react-map-gl usage in our products. In the demos and examples there is* consistent usage of useCallback for event handlers, even when they might not have any dependencies. I personally find this as a good safety point as I know event handling within mapbox can become complicated once we look at the interaction with React and the many layers within the map. My colleagues however are not convinced there is sufficient reason for this. More specifically I want to introduce a rule use useCallback on all map event handlers.
How can I justify this without asking people to use performance tools in all circumstances to find out when to use useCallback or not?
Is there an implementation detail within react-map-gl that would lend us to use useCallback on event handlers?
Is it something to do with how many times the map binds that same event handler to different internal layers and how we want to minimize the chance that React rendering will interfere with this?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, we are currently spiking
react-map-gl
usage in our products. In the demos and examples there is* consistent usage ofuseCallback
for event handlers, even when they might not have any dependencies. I personally find this as a good safety point as I know event handling within mapbox can become complicated once we look at the interaction with React and the many layers within the map. My colleagues however are not convinced there is sufficient reason for this. More specifically I want to introduce a rule useuseCallback
on all map event handlers.How can I justify this without asking people to use performance tools in all circumstances to find out when to use
useCallback
or not?Is there an implementation detail within
react-map-gl
that would lend us to useuseCallback
on event handlers?Is it something to do with how many times the map binds that same event handler to different internal layers and how we want to minimize the chance that React rendering will interfere with this?
Beta Was this translation helpful? Give feedback.
All reactions