Skip to content

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

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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