I am creating a custom widget in ArcGIS experience builder and am trying to get a list of all the widgets currently defined for a page or for the entire app inside the setting UI.
I tried using the widget state to transfer the list, as well as create it in a similar way to the one used in the Control the Widget State example, but when I use the same code in setting.tsx I get the widgets that are used to create the settings UI sidebar, and not the current app/page widgets.
For example, when I run:
import { React, getAppStore } from 'jimu-core';
const { useState, useEffect } = React
let state = getAppStore().getState();
const [appWidgets, setAppWidgets] = useState({} as unknown)
const [widgetsArray, setWidgetsArray] = useState([] as any[])
// Update the appWidgets property once, on page load
useEffect(() => {
const widgets = state.appConfig.widgets
setAppWidgets(widgets)
}, [state])
// Update the widgetsArray and sidebarWidgetsArray properties every time appWidgets changes
useEffect(() => {
if(appWidgets) {
const widgetsArray = Object.values(appWidgets)
setWidgetsArray(widgetsArray)
}
}, [appWidgets])Then widgetsArray is supposed to contain all of the widgets in the app, which works if run inside widget.tsx, but in setting.tsx I get a list of the setting UI components.
I know the process should be possible, because the MapWidgetSelector component from 'jimu-ui/advanced/setting-components' uses it to grab just the map components, but its code isn't open and I can't find how it's taking the widgets defined for a page.
Is there an efficient way to get all of the widgets in a specific app/page into the settings UI?