File tree Expand file tree Collapse file tree 3 files changed +4015
-3467
lines changed Expand file tree Collapse file tree 3 files changed +4015
-3467
lines changed Original file line number Diff line number Diff line change 7575 "jsdom" : " ^15.0.0" ,
7676 "ocular-dev-tools" : " ^0.2.2" ,
7777 "pre-commit" : " ^1.2.2" ,
78- "react" : " ^16.3 .0" ,
79- "react-dom" : " ^16.3 .0" ,
78+ "react" : " ^18.2 .0" ,
79+ "react-dom" : " ^18.2 .0" ,
8080 "react-test-renderer" : " ^16.3.0" ,
8181 "reify" : " ^0.18.1" ,
8282 "sinon" : " 4.1.3" ,
8383 "typescript" : " ^4.0.0"
8484 },
8585 "peerDependencies" : {
86- "react" : " >=16.3.0"
86+ "react" : " ^18.2.0" ,
87+ "react-dom" : " ^18.2.0"
8788 },
8889 "pre-commit" : [
8990 " test-fast"
Original file line number Diff line number Diff line change @@ -209,13 +209,17 @@ export default class Goong {
209209 this . _map = Goong . savedMap ;
210210 // When reusing the saved map, we need to reparent the map(canvas) and other child nodes
211211 // intoto the new container from the props.
212- // Step1: reparenting child nodes from old container to new container
212+ // Step1: reparenting child nodes from old container to new container, do not execute if same element, otherwise will loop and crash.
213213 const oldContainer = this . _map . getContainer ( ) ;
214214 const newContainer = props . container ;
215215 newContainer . classList . add ( 'mapboxgl-map' ) ;
216- while ( oldContainer . childNodes . length > 0 ) {
217- newContainer . appendChild ( oldContainer . childNodes [ 0 ] ) ;
216+
217+ if ( oldContainer !== newContainer ) {
218+ while ( oldContainer . childNodes . length > 0 ) {
219+ newContainer . appendChild ( oldContainer . childNodes [ 0 ] ) ;
220+ }
218221 }
222+
219223 // Step2: replace the internal container with new container from the react component
220224 this . _map . _container = newContainer ;
221225 Goong . savedMap = null ;
@@ -285,7 +289,7 @@ export default class Goong {
285289 return ;
286290 }
287291
288- if ( ! Goong . savedMap ) {
292+ if ( ! this . props . reuseMaps && ! Goong . savedMap ) {
289293 Goong . savedMap = this . _map ;
290294
291295 // deregister the goong event listeners
You can’t perform that action at this time.
0 commit comments