We just upgraded to ArcGIS Enterprise 11.1 and I am playing with custom experience builder widgets.
I have a widget that loads, but only if the map and layers finish loading first. If the user clicks the button too soon the widget errors with a message
“Cannot read properties of null (reading 'view')”
(See screenshot attached).
I figured out that it happens because the app isn’t fully finished loading so the mapView is null.
const viewManager = MapViewManager.getInstance();
console.log(viewManager); // is not null if widget loaded too soon
const mapView = viewManager.getJimuMapViewById(viewManager.getAllJimuMapViewIds()[0]);
console.log(mapView); // returns null if widget loaded too soon
As long as the user waits long enough, mapView will not be null. But if pressed too quickly it is null.
In an Experience Builder React widget, is there a way to only load the widget after the map and layers finish loading? (Kind of like how the Esri JS SDK has the view.when, or something like that). Or is there some other way of getting the same result? That way, even if the user clicks the button too soon to open the widget, it will still load only after the map and layers finish and won’t error.
Thanks!
FYI: I am an extreme newbie with React and Experience Builder custom widgets.