@@ -291,62 +291,62 @@ const ReactMapboxFactory = ({
291291 }
292292 }
293293
294- public UNSAFE_componentWillReceiveProps ( nextProps : Props & Events ) {
294+ public componentDidUpdate ( prevProps : Props & Events ) {
295295 const { map } = this . state ;
296296 if ( ! map ) {
297297 return null ;
298298 }
299299
300300 // Update event listeners
301- this . listeners = updateEvents ( this . listeners , nextProps , map ) ;
301+ this . listeners = updateEvents ( this . listeners , this . props , map ) ;
302302
303303 const center = map . getCenter ( ) ;
304304 const zoom = map . getZoom ( ) ;
305305 const bearing = map . getBearing ( ) ;
306306 const pitch = map . getPitch ( ) ;
307307
308308 const didZoomUpdate =
309- this . props . zoom !== nextProps . zoom &&
310- ( nextProps . zoom && nextProps . zoom [ 0 ] ) !== zoom ;
309+ prevProps . zoom !== this . props . zoom &&
310+ ( this . props . zoom && this . props . zoom [ 0 ] ) !== zoom ;
311311
312312 const didCenterUpdate =
313- this . props . center !== nextProps . center &&
314- ( ( nextProps . center && nextProps . center [ 0 ] ) !== center . lng ||
315- ( nextProps . center && nextProps . center [ 1 ] ) !== center . lat ) ;
313+ prevProps . center !== this . props . center &&
314+ ( ( this . props . center && this . props . center [ 0 ] ) !== center . lng ||
315+ ( this . props . center && this . props . center [ 1 ] ) !== center . lat ) ;
316316
317317 const didBearingUpdate =
318- this . props . bearing !== nextProps . bearing &&
319- ( nextProps . bearing && nextProps . bearing [ 0 ] ) !== bearing ;
318+ prevProps . bearing !== this . props . bearing &&
319+ ( this . props . bearing && this . props . bearing [ 0 ] ) !== bearing ;
320320
321321 const didPitchUpdate =
322- this . props . pitch !== nextProps . pitch &&
323- ( nextProps . pitch && nextProps . pitch [ 0 ] ) !== pitch ;
322+ prevProps . pitch !== this . props . pitch &&
323+ ( this . props . pitch && this . props . pitch [ 0 ] ) !== pitch ;
324324
325- if ( nextProps . maxBounds ) {
326- const didMaxBoundsUpdate = this . props . maxBounds !== nextProps . maxBounds ;
325+ if ( this . props . maxBounds ) {
326+ const didMaxBoundsUpdate = prevProps . maxBounds !== this . props . maxBounds ;
327327
328328 if ( didMaxBoundsUpdate ) {
329- map . setMaxBounds ( nextProps . maxBounds ) ;
329+ map . setMaxBounds ( this . props . maxBounds ) ;
330330 }
331331 }
332332
333- if ( nextProps . fitBounds ) {
334- const { fitBounds } = this . props ;
333+ if ( this . props . fitBounds ) {
334+ const { fitBounds } = prevProps ;
335335
336336 const didFitBoundsUpdate =
337- fitBounds !== nextProps . fitBounds || // Check for reference equality
338- nextProps . fitBounds . length !== ( fitBounds && fitBounds . length ) || // Added element
337+ fitBounds !== this . props . fitBounds || // Check for reference equality
338+ this . props . fitBounds . length !== ( fitBounds && fitBounds . length ) || // Added element
339339 ! ! fitBounds . filter ( ( c , i ) => {
340340 // Check for equality
341- const nc = nextProps . fitBounds && nextProps . fitBounds [ i ] ;
341+ const nc = this . props . fitBounds && this . props . fitBounds [ i ] ;
342342 return c [ 0 ] !== ( nc && nc [ 0 ] ) || c [ 1 ] !== ( nc && nc [ 1 ] ) ;
343343 } ) [ 0 ] ;
344344
345345 if (
346346 didFitBoundsUpdate ||
347- ! isEqual ( this . props . fitBoundsOptions , nextProps . fitBoundsOptions )
347+ ! isEqual ( prevProps . fitBoundsOptions , this . props . fitBoundsOptions )
348348 ) {
349- map . fitBounds ( nextProps . fitBounds , nextProps . fitBoundsOptions , {
349+ map . fitBounds ( this . props . fitBounds , this . props . fitBoundsOptions , {
350350 fitboundUpdate : true
351351 } ) ;
352352 }
@@ -358,21 +358,21 @@ const ReactMapboxFactory = ({
358358 didBearingUpdate ||
359359 didPitchUpdate
360360 ) {
361- const mm : string = nextProps . movingMethod || defaultMovingMethod ;
362- const { flyToOptions, animationOptions } = nextProps ;
361+ const mm : string = this . props . movingMethod || defaultMovingMethod ;
362+ const { flyToOptions, animationOptions } = this . props ;
363363
364364 map [ mm ] ( {
365365 ...animationOptions ,
366366 ...flyToOptions ,
367- zoom : didZoomUpdate && nextProps . zoom ? nextProps . zoom [ 0 ] : zoom ,
368- center : didCenterUpdate ? nextProps . center : center ,
369- bearing : didBearingUpdate ? nextProps . bearing : bearing ,
370- pitch : didPitchUpdate ? nextProps . pitch : pitch
367+ zoom : didZoomUpdate && this . props . zoom ? this . props . zoom [ 0 ] : zoom ,
368+ center : didCenterUpdate ? this . props . center : center ,
369+ bearing : didBearingUpdate ? this . props . bearing : bearing ,
370+ pitch : didPitchUpdate ? this . props . pitch : pitch
371371 } ) ;
372372 }
373373
374- if ( ! isEqual ( this . props . style , nextProps . style ) ) {
375- map . setStyle ( nextProps . style ) ;
374+ if ( ! isEqual ( prevProps . style , this . props . style ) ) {
375+ map . setStyle ( this . props . style ) ;
376376 }
377377
378378 return null ;
0 commit comments