Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix markers rerender when click to open InfoWindow#310

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
deadkff01 wants to merge3 commits intofullstackreact:master
base:master
Choose a base branch
Loading
fromdeadkff01:fix-marker-rerender

Conversation

deadkff01
Copy link

@deadkff01deadkff01 commentedJan 28, 2019
edited
Loading

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.

hurstindustries, FelixSchwarzmeier, NicksonT, julisalis, cesar-cb, alokyadav15, m-bartenev, and brodly reacted with thumbs up emoji
@m-bartenev
Copy link

@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?
Thanks

deadkff01 reacted with thumbs up emoji

@deadkff01
Copy link
Author

@m-bartenev, I did the comparison incomponentDidUpdate only to keep the same code structure. :)

@m-bartenev
Copy link

@deadkff01 , I see :) Thank you for your answer!

@srobertson421
Copy link

To anyone who comes across this bug, here is a patch you can use until things are merged, should stop the constant re-renders:

class CustomMarker extends Marker {  componentDidUpdate(prevProps) {    if(      this.props.map !== prevProps.map ||       this.props.icon.url !== prevProps.icon.url ||       (        this.props.position.lat !== prevProps.position.lat ||         this.props.position.lng !== prevProps.position.lng      )    ) {      if(this.marker) {        this.marker.setMap(null);      }      this.renderMarker();    }  }}
deadkff01, shashank-naik, and Squdward reacted with thumbs up emojimarkhowellsmead and Squdward reacted with rocket emoji

@deadkff01
Copy link
Author

Nice@srobertson421

@@ -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)

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

deadkff01 reacted with thumbs up emoji
Copy link
Author

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.

Copy link
Author

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sschollesschollesscholle requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@deadkff01@m-bartenev@srobertson421@sscholle

[8]ページ先頭

©2009-2025 Movatter.jp