Select to view content in your preferred language

Custom widget occasionally failing to load

230
1
05-07-2024 05:20 AM
HarryBonshor-Mayes
New Contributor II

Hello,

I have a custom widget which, when loading correctly, appears like this:

HarryBonshorMayes_0-1715084220265.png

This works 90% of the time in the experience builder, but when viewing the published experience it loads around 30% of the time. 

It seems to be loading before the data and so fails and shows this:

HarryBonshorMayes_1-1715084271112.png

 

Refreshing until it loads solves this. 

Would it be possible to add some sort of delay at the start which would give time for other resources to load or is there another underlying issue?

Thanks for any help.

 

0 Kudos
1 Reply
JeffreyThompson2
MVP Regular Contributor

You can use a setTimeout() function if you just want to add a delay, but you will get better results finding out why your widget isn't loading.

Do you have any console errors? Chances are the issue relates to jimuMapView or a map layer loading slower than your widget. Consider using a useEffect() function and/or reactiveUtils to watch for the data.

GIS Developer
City of Arlington, Texas
0 Kudos