Skip to content

Fixed issue with redundant mounting/unmounting + better position check#16

Open
omerts wants to merge 4 commits intojgimbel:masterfrom
omerts:master
Open

Fixed issue with redundant mounting/unmounting + better position check#16
omerts wants to merge 4 commits intojgimbel:masterfrom
omerts:master

Conversation

@omerts
Copy link

@omerts omerts commented Jul 17, 2018

Hey,

Since the ContextProvider component was created in the renderComponent function, it caused react to mount and unmount the component on every render, since renderComponent created a new ContextProvider class every time. We had a marker with an image in it, and we could see the image reload on every render. If you put a componentDidMount in your inner component you can see it being raised on every render.
We have moved the creating of the ContextProvider to the componentDidMount, as there is no real reason to create it every time, specifically since context is added statically and doesn't change in runtime.

We also we have changed the comparison of the position, since if you use the component like:

<DivIcon position={[this.props.lat, this.props.lng]}

It will cause the setLatLng function to be called even if nothing changed, since the comparison was done by array reference.

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

Successfully merging this pull request may close these issues.

2 participants