Select to view content in your preferred language

Lifecycle issue with @arcgis/map-components-react

210
2
Jump to solution
09-16-2024 03:00 AM
jvpelt
by
Emerging Contributor

Hi, 

Got a lifecycle issue in my react application I can't seem to figure out. Hopefully someone can point me in the right direction. 

Situation: I've got a React SPA which has a map on several components this is working fine on the initial rendering and while interacting on the given component. The issue occurs when navigating away from the component I'll get the following errors in the console:

jvpelt_0-1726480593374.png

 

After these errors have been thrown the map does not behave as intended for example the expand widget no longer loads: 

Initial load:

jvpelt_1-1726480658485.png

Loading a map after the errors:

jvpelt_2-1726480696758.png

 

I can't seem to find anything in the documentation about the need to manually clean up any references or something so any help regarding this issue will be highly appreciated  

 

"@arcgis/core": "^4.30.9",
"@arcgis/map-components-react": "^4.30.7",

 

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

If you had a github repro, would be easier to tell. One thing you can do is add the "autoDestroyDisabled" to your components. All the map components have it.

https://developers.arcgis.com/javascript/latest/references/map-components/?path=/docs/component-refe...

From the description:


If true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporary hide it. If this is set, make sure to call the `destroy` method when you are done to prevent memory leaks.

 


 

View solution in original post

0 Kudos
2 Replies
ReneRubalcava
Honored Contributor

If you had a github repro, would be easier to tell. One thing you can do is add the "autoDestroyDisabled" to your components. All the map components have it.

https://developers.arcgis.com/javascript/latest/references/map-components/?path=/docs/component-refe...

From the description:


If true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporary hide it. If this is set, make sure to call the `destroy` method when you are done to prevent memory leaks.

 


 

0 Kudos
jvpelt
by
Emerging Contributor

Thanks! This solved the issue!