-
Notifications
You must be signed in to change notification settings - Fork 818
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
fix markers rerender when click to open InfoWindow #310
base: master
Are you sure you want to change the base?
Conversation
@deadkff01 , I came across that issue recently. I did the same comparison but in shouldComponentUpdate method. Can I ask you why you've opted to the componentDidUpdate? |
@m-bartenev, I did the comparison in |
@deadkff01 , I see :) Thank you for your answer! |
To anyone who comes across this bug, here is a patch you can use until things are merged, should stop the constant re-renders:
|
Nice @srobertson421 |
src/components/Marker.js
Outdated
@@ -36,7 +36,9 @@ export class Marker extends React.Component { | |||
|
|||
componentDidUpdate(prevProps) { | |||
if ((this.props.map !== prevProps.map) || | |||
(this.props.position !== prevProps.position) || | |||
((this.props.position && prevProps.position) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most unreadable, please rather use a function such as 'arePositionsEqual' to simplify readability. thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it's been a long time, I'll see if this change still makes sense, if so, I'll make the change later.
Thanks for the feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem still persists in the current version of the lib.
I solved your issue in the last commits.
Solving issue #269
In Marker.js componentDidUpdate()
this.props.position
andprevProps.position
will never be equal after component is fully rendered in first time, because these properties are objects, for this reason I use thelat
andlng
to compare after the first rendering.