Hi, I’m trying to use a “select” component in an app that uses a dql result as a select options source. The problem is that when the app tries to render the component it returns an error:
main.js:102916 Uncaught Error: There are more children items inside the Select component than items inside the Select collection. Please check if the id of the SelectOption components is unique.
at validateNesting (main.js:102916:13)
at main.js:103073:7
at invokePassiveEffectCreate (main.js:19996:31)
at HTMLUnknownElement.callCallback2 (main.js:6910:24)
at Object.invokeGuardedCallbackDev (main.js:6935:26)
at invokeGuardedCallback (main.js:6969:41)
at flushPassiveEffectsImpl (main.js:20058:19)
at unstable_runWithPriority (main.js:3585:22)
at runWithPriority$1 (main.js:11707:20)
at flushPassiveEffects (main.js:19962:24)
but the select options array seems to be ok, without duplicates:
[
"<SelectOption id=\"GDN-DT-ORA19\">GDN-DT-ORA19</SelectOption>",
"<SelectOption id=\"GDNVTUBU2004-1\">GDNVTUBU2004-1</SelectOption>",
"<SelectOption id=\"GDNVTWIN1064LM1\">GDNVTWIN1064LM1</SelectOption>",
"<SelectOption id=\"HOST-CWS-4-IG-1-HG-200001\">HOST-CWS-4-IG-1-HG-200001</SelectOption>",
"<SelectOption id=\"HOST-CWS-4-IG-1-HG-200002\">HOST-CWS-4-IG-1-HG-200002</SelectOption>",
...
this is my code to fill the array from dql results object:
const query = "fetch dt.entity.host | fields entity.name | summarize count(), by:{entity.name} | fields entity.name";
const [resultDql, setResult] = useState<QueryResult>();
useEffect(() => {
queryExecutionClient.queryExecute({
body: {
query,
requestTimeoutMilliseconds: 30000,
},
})
.then((res) => setResult(res.result));
}, []);
var arr : any[] = [];
resultDql?.records?.forEach(function (value) {
if (value != null ) {
arr.push("<SelectOption id=\"" + value['entity.name']?.toString() + "\">" + value['entity.name'] + "</SelectOption>");
}
});
and the select field:
<Select name="Host"
selectedId={singleValueHost}
onChange={setSingleValueHost}
hasFilter>
{ arr }
</Select>