Moving Typescript application to react + Typescript with ArcGIS JS API 4.18

493
4
Jump to solution
03-26-2021 11:36 AM
divyabathina
New Contributor III

Hi All,

The support documents for frameworks in ArcGIS JS API present before are not found now wondering if they will be added? Looking for sample project to solve below issues

How to use import esri = ___esri in react + Typescript with ArcGIS JS API 4.18

Having below issue with View container able to fix it by adding as any. Looking for any better way?

Screenshot 2021-03-26 at 18.26.53.png

Many Thanks,

Divya

 

 

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

mapDiv.current as HTMLDivElement

View solution in original post

0 Kudos
4 Replies
ReneRubalcava
Frequent Contributor

The ref.current from useRef can be Element or undefined. Try to do something like this.

 

 

if (mapRef.current) {
  // mapRef.current typing should now be inferred as HTMLDivElement
}

 

 

If all else fails you can say "as HTMLDivElement"

 

You can find framework samples on github now.

https://github.com/Esri/jsapi-resources/tree/master/esm-samples

Using the ESM build of @Anonymous User/core doesn't really require framework specific guides anymore. You just integrate it pretty much how you would any third-party library.

DivyaBathina1
New Contributor

Hi Rene,

Thanks for looking into this issue. Yes we have followed the same sample link which was useful. 

Tried to do like below but still have issue and ui code is <div className="mapDiv" ref={mapDiv}></div>

DivyaBathina1_1-1617037719446.png

Thanks,

Divya 

 

 

0 Kudos
ReneRubalcava
Frequent Contributor

mapDiv.current as HTMLDivElement

View solution in original post

0 Kudos
divyabathina
New Contributor III

its working now!!Thank you

0 Kudos