diff --git a/src/google_map_markers.js b/src/google_map_markers.js index c619e7c..e2fbb66 100644 --- a/src/google_map_markers.js +++ b/src/google_map_markers.js @@ -48,13 +48,6 @@ export default class GoogleMapMarkers extends Component { constructor(props) { super(props); - this.props.dispatcher.on('kON_CHANGE', this._onChangeHandler); - this.props.dispatcher.on( - 'kON_MOUSE_POSITION_CHANGE', - this._onMouseChangeHandler - ); - this.props.dispatcher.on('kON_CLICK', this._onChildClick); - this.props.dispatcher.on('kON_MDOWN', this._onChildMouseDown); this.dimensionsCache_ = {}; this.hoverKey_ = null; @@ -64,6 +57,16 @@ export default class GoogleMapMarkers extends Component { this.state = { ...this._getState(), hoverKey: null }; } + componentDidMount() { + this.props.dispatcher.on('kON_CHANGE', this._onChangeHandler); + this.props.dispatcher.on( + 'kON_MOUSE_POSITION_CHANGE', + this._onMouseChangeHandler + ); + this.props.dispatcher.on('kON_CLICK', this._onChildClick); + this.props.dispatcher.on('kON_MDOWN', this._onChildMouseDown); + } + shouldComponentUpdate(nextProps, nextState) { if (this.props.experimental === true) { return (