Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unnecessary renders caused by marker? #34

Open
ckalas opened this issue May 2, 2018 · 2 comments
Open

unnecessary renders caused by marker? #34

ckalas opened this issue May 2, 2018 · 2 comments

Comments

@ckalas
Copy link

ckalas commented May 2, 2018

I draw a bunch of markers into my map, each marker is just some simple svg shapes. When I inspect it in react tools it appears to be rerendering the markers and hence the map when I mouse over the marker area. At the moment I only have a handful of markers but when its in production it will have siginficantly more and I am trying to understand the reason behind it rerendering.

Even if BasicMarker just renders a div with static text it is rerendering.

<GoogleMap center={ {lat: 31.299, lng: 120.5853} } zoom={8}> {value.map(c => <BasicMarker key={c.lat.toString() + c.lon.toString()} text={""} lat={c.lat} lng={c.lon} />)} </GoogleMap>

@ckalas ckalas changed the title unnecessary renders caused my marker? unnecessary renders caused by marker? May 2, 2018
@dave4jr
Copy link

dave4jr commented May 26, 2019

@ckalas I'm seeing the same issue.. Did you solve this by chance?

@dave4jr
Copy link

dave4jr commented May 27, 2019

For anyone else who see this, the way I solved this was to use react PureComponent, which implements shouldComponentUpdate, which does a shallow comparison and only re-renders upon a change. This solved the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants