File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -216,9 +216,6 @@ export default class Mapbox {
216216 this . props = props ;
217217
218218 const settingsChanged = this . _updateSettings ( props , oldProps ) ;
219- if ( settingsChanged ) {
220- this . _createProxyTransform ( this . _map ) ;
221- }
222219 const sizeChanged = this . _updateSize ( props ) ;
223220 const viewStateChanged = this . _updateViewState ( props , true ) ;
224221 this . _updateStyle ( props , oldProps ) ;
Original file line number Diff line number Diff line change @@ -147,6 +147,40 @@ test('Map#controlled#no-update', t => {
147147 ) ;
148148} ) ;
149149
150+ test ( 'Map#uncontrolled#delayedSettingsUpdate' , async t => {
151+ const root = createRoot ( document . createElement ( 'div' ) ) ;
152+ const mapRef = { current : null } ;
153+
154+ function App ( ) {
155+ const [ settings , setSettings ] = React . useState ( {
156+ maxPitch : 85
157+ } ) ;
158+
159+ async function onLoad ( ) {
160+ await sleep ( 1 ) ;
161+ setSettings ( { maxPitch : 60 } ) ;
162+ }
163+
164+ return (
165+ < Map
166+ ref = { mapRef }
167+ mapLib = { import ( 'mapbox-gl-v3' ) }
168+ mapboxAccessToken = { MapboxAccessToken }
169+ initialViewState = { { longitude : - 100 , latitude : 40 , zoom : 4 } }
170+ { ...settings }
171+ onLoad = { onLoad }
172+ />
173+ ) ;
174+ }
175+
176+ root . render ( < App /> ) ;
177+
178+ await waitForMapLoad ( mapRef ) ;
179+ await sleep ( 1 ) ;
180+
181+ t . is ( mapRef . current . getMaxPitch ( ) , 60 , 'maxPitch is updated' ) ;
182+ } ) ;
183+
150184test ( 'Map#controlled#mirror-back' , t => {
151185 const root = createRoot ( document . createElement ( 'div' ) ) ;
152186 const mapRef = { current : null } ;
You can’t perform that action at this time.
0 commit comments