Skip to content

Commit 579dad3

Browse files
committed
Fix unnecessary marker re-render
1 parent f1e1200 commit 579dad3

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

dist/components/Marker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
}, {
136136
key: 'componentDidUpdate',
137137
value: function componentDidUpdate(prevProps) {
138-
if (this.props.map !== prevProps.map || this.props.position !== prevProps.position || this.props.icon !== prevProps.icon) {
138+
if (this.props.map !== prevProps.map || this.props.position.lat() !== prevProps.lat() || this.props.position.lng() !== prevProps.lng() || this.props.icon !== prevProps.icon) {
139139
if (this.marker) {
140140
this.marker.setMap(null);
141141
}

src/components/Marker.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export class Marker extends React.Component {
3636

3737
componentDidUpdate(prevProps) {
3838
if ((this.props.map !== prevProps.map) ||
39-
(this.props.position !== prevProps.position) ||
39+
(this.props.position.lat() !== prevProps.lat()) ||
40+
(this.props.position.lng() !== prevProps.lng()) ||
4041
(this.props.icon !== prevProps.icon)) {
4142
if (this.marker) {
4243
this.marker.setMap(null);

0 commit comments

Comments
 (0)