mirror of
https://github.com/google-map-react/google-map-react.git
synced 2025-12-08 18:26:32 +00:00
Merge pull request #170 from istarkov/remove-draggable
Remove draggable from shallowEqual
This commit is contained in:
commit
5f443f8a1c
@ -40,9 +40,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"eventemitter3": "^1.1.0",
|
||||
"fbjs": "^0.8.3",
|
||||
"lodash": "^4.6.1",
|
||||
"point-geometry": "0.0.0",
|
||||
"react-pure-render": "^1.0.1",
|
||||
"scriptjs": "^2.5.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React, {PropTypes, Component} from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import shouldPureComponentUpdate from 'react-pure-render/function';
|
||||
import shallowEqual from 'fbjs/lib/shallowEqual';
|
||||
|
||||
import MarkerDispatcher from './marker_dispatcher';
|
||||
|
||||
@ -22,7 +22,7 @@ import log2 from './utils/math/log2';
|
||||
|
||||
import assign from 'lodash/assign';
|
||||
import isNumber from 'lodash/isNumber';
|
||||
|
||||
import omit from './utils/omit';
|
||||
|
||||
const kEPS = 0.00001;
|
||||
const K_GOOGLE_TILE_SIZE = 256;
|
||||
@ -262,7 +262,13 @@ export default class GoogleMap extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
shouldComponentUpdate = shouldPureComponentUpdate;
|
||||
shouldComponentUpdate(nextProps) {
|
||||
// draggable does not affect inner components
|
||||
return !shallowEqual(
|
||||
omit(this.props, ['draggable']),
|
||||
omit(nextProps, ['draggable'])
|
||||
);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
this.markersDispatcher_.emit('kON_CHANGE');
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import React, {PropTypes, Component} from 'react';
|
||||
|
||||
import shouldPureComponentUpdate from 'react-pure-render/function';
|
||||
import shallowEqual from 'fbjs/lib/shallowEqual';
|
||||
|
||||
const mainStyle = {
|
||||
width: '100%',
|
||||
@ -56,7 +55,9 @@ export default class GoogleMapMarkers extends Component {
|
||||
this.state = {...this._getState(), hoverKey: null};
|
||||
}
|
||||
|
||||
shouldComponentUpdate = shouldPureComponentUpdate;
|
||||
shouldComponentUpdate(nextProps) {
|
||||
return !shallowEqual(this.props, nextProps);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.dispatcher.removeListener('kON_CHANGE', this._onChangeHandler);
|
||||
|
||||
13
src/utils/omit.js
Normal file
13
src/utils/omit.js
Normal file
@ -0,0 +1,13 @@
|
||||
// https://github.com/acdlite/recompose/blob/master/src/packages/recompose/utils/omit.js
|
||||
const omit = (obj, keys) => {
|
||||
const { ...rest } = obj;
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (rest.hasOwnProperty(key)) {
|
||||
delete rest[key];
|
||||
}
|
||||
}
|
||||
return rest;
|
||||
};
|
||||
|
||||
export default omit;
|
||||
Loading…
x
Reference in New Issue
Block a user