Select to view content in your preferred language

Query feature layer in React function component with Experience Builder developer edition v1.14

392
4
Jump to solution
08-21-2024 05:33 PM
Labels (1)
Ming
by
Frequent Contributor

Anyone has experience to query feature layer in React function component with Experience Builder developer edition v1.14? Following simple code just failed to load.

import Query from 'esri/rest/support/Query'
 
export default function Filter () {
      const query = new Query()
}
 
It can load if remove that one line Query code. ChatGPT says "Using esri/rest/support/Query in a React function component can be challenging due to the asynchronous nature of the ArcGIS API and the lifecycle of React components. ", so changed to use useEffect, useRef, but still doesn't work.
 
Thanks for any suggestion!
1 Solution

Accepted Solutions
Junshan_Liu
Frequent Contributor

Oh, can you add the "dependency": "jimu-arcgis", into the widget manifest.json?

View solution in original post

0 Kudos
4 Replies
Junshan_Liu
Frequent Contributor

What errors do you see after using the useEffect?

0 Kudos
Ming
by
Frequent Contributor

Thank you @Junshan_Liu very much for response. On GUI it shows same message "Fail to load".

erro1.jpg

 

The detailed error is:

erro2.jpg

 

 

0 Kudos
Junshan_Liu
Frequent Contributor

Oh, can you add the "dependency": "jimu-arcgis", into the widget manifest.json?

0 Kudos
Ming
by
Frequent Contributor

@Junshan_Liu Thank you so much for your magical power, it works now, cheers!

Thanks!.jpg

0 Kudos