react-google-maps-api icon indicating copy to clipboard operation
react-google-maps-api copied to clipboard

GoogleMap rerender on setSate in functionnal component

Open frankboris opened this issue 4 years ago • 3 comments

Hi all, I just created an example app using react and google map api. Everything works fine for the http queries. But the map reloads when I use setSate to save the result. Here is the link to test and see the errors: https://google-distance.herokuapp.com Github repository link for source code: https://github.com/frankboris/google-map-app

OS: windows

node --version 7.20.0

react version 17.0.2

@react-google-maps/api version 2.2.0

frankboris avatar Aug 09 '21 10:08 frankboris

please provide minimal reproduction on codesandbox.io

JustFly1984 avatar Aug 09 '21 23:08 JustFly1984

Here is my codesandbox.io link

https://codesandbox.io/s/eloquent-hopper-16k2e

frankboris avatar Aug 10 '21 00:08 frankboris

@frankboris In your case it is easy - you need to isolate each state in separate component, and use React.memo on each component export. Also use eslint with eslint-perf plugin, it will help you to figure out performance issues.

JustFly1984 avatar Aug 11 '21 11:08 JustFly1984