Fix: React 18 markers (#1224)

* disable batching for _onChange listener

* correctly reset cache

* move flushsync out of lifecycle method
This commit is contained in:
Ben Hodgson 2025-05-24 05:28:08 +10:00 committed by GitHub
parent 743aaa3b4c
commit 5776154425
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View File

@ -1,7 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies, react/forbid-prop-types, no-console, no-undef */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import ReactDOM, { flushSync } from 'react-dom';
// helpers
import GoogleMapMap from './google_map_map';
@ -703,7 +703,9 @@ class GoogleMap extends Component {
this_._onChildMouseMove();
if (this_.markersDispatcher_) {
this_.markersDispatcher_.emit('kON_CHANGE');
flushSync(() => {
this_.markersDispatcher_.emit('kON_CHANGE');
})
if (this_.fireMouseEventOnIdle_) {
this_.markersDispatcher_.emit('kON_MOUSE_POSITION_CHANGE');
}

View File

@ -93,7 +93,7 @@ export default class GoogleMapMarkers extends Component {
this.props.dispatcher.removeListener('kON_CLICK', this._onChildClick);
this.props.dispatcher.removeListener('kON_MDOWN', this._onChildMouseDown);
this.dimensionsCache_ = null;
this.dimensionsCache_ = {};
}
_getState = () => ({