mirror of
https://github.com/visgl/react-map-gl.git
synced 2025-12-08 20:16:02 +00:00
fix: max depth exceeded error when dynamically changing map settings (#2535)
This commit is contained in:
parent
6bf0a3771e
commit
465bd4bbc7
@ -216,9 +216,6 @@ export default class Mapbox {
|
||||
this.props = props;
|
||||
|
||||
const settingsChanged = this._updateSettings(props, oldProps);
|
||||
if (settingsChanged) {
|
||||
this._createProxyTransform(this._map);
|
||||
}
|
||||
const sizeChanged = this._updateSize(props);
|
||||
const viewStateChanged = this._updateViewState(props, true);
|
||||
this._updateStyle(props, oldProps);
|
||||
|
||||
@ -147,6 +147,40 @@ test('Map#controlled#no-update', t => {
|
||||
);
|
||||
});
|
||||
|
||||
test('Map#uncontrolled#delayedSettingsUpdate', async t => {
|
||||
const root = createRoot(document.createElement('div'));
|
||||
const mapRef = {current: null};
|
||||
|
||||
function App() {
|
||||
const [settings, setSettings] = React.useState({
|
||||
maxPitch: 85
|
||||
});
|
||||
|
||||
async function onLoad() {
|
||||
await sleep(1);
|
||||
setSettings({maxPitch: 60});
|
||||
}
|
||||
|
||||
return (
|
||||
<Map
|
||||
ref={mapRef}
|
||||
mapLib={import('mapbox-gl-v3')}
|
||||
mapboxAccessToken={MapboxAccessToken}
|
||||
initialViewState={{longitude: -100, latitude: 40, zoom: 4}}
|
||||
{...settings}
|
||||
onLoad={onLoad}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
root.render(<App />);
|
||||
|
||||
await waitForMapLoad(mapRef);
|
||||
await sleep(1);
|
||||
|
||||
t.is(mapRef.current.getMaxPitch(), 60, 'maxPitch is updated');
|
||||
});
|
||||
|
||||
test('Map#controlled#mirror-back', t => {
|
||||
const root = createRoot(document.createElement('div'));
|
||||
const mapRef = {current: null};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user