<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic TypeScript missing 'undefined' for view.container property in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-missing-undefined-for-view-container/m-p/1270311#M80618</link>
    <description>&lt;P&gt;ArcGis version:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"@arcgis/core"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"4.26.5"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to your own post about using ArcGis with React, we should have a useEffect that unsets the views container, which seems like the way to go for freeing up the resources \ WebGL contexts created.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;useEffect(() =&amp;gt; {
    ... Map initialization

    return () =&amp;gt; (view.container = null);
  }, []);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.esri.com/about/newsroom/arcuser/react-arcgis/" target="_blank" rel="noopener"&gt;Using React with the ArcGIS API for JavaScript (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But your Typescript definition says that view.container needs to be a HTMLDivElement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  export class DOMContainer {
    /**
     * The `id` or node representing the DOM element containing the view.
     *
     * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#container)
     */
    container: HTMLDivElement;
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While you initializer allows more options:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  interface DOMContainerProperties {
    /**
     * The `id` or node representing the DOM element containing the view.
     *
     * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#container)
     */
    container?: HTMLDivElement | string;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The workaround is to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;useEffect(() =&amp;gt; {
    ... Map initialization

    return () =&amp;gt; (view.container = null as any);
  }, []);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i believe the Typescript definition should be updated, if this is the preferred way to cleanup.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Mar 2023 11:59:40 GMT</pubDate>
    <dc:creator>Christer</dc:creator>
    <dc:date>2023-03-22T11:59:40Z</dc:date>
    <item>
      <title>TypeScript missing 'undefined' for view.container property</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-missing-undefined-for-view-container/m-p/1270311#M80618</link>
      <description>&lt;P&gt;ArcGis version:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"@arcgis/core"&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;"4.26.5"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to your own post about using ArcGis with React, we should have a useEffect that unsets the views container, which seems like the way to go for freeing up the resources \ WebGL contexts created.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;useEffect(() =&amp;gt; {
    ... Map initialization

    return () =&amp;gt; (view.container = null);
  }, []);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.esri.com/about/newsroom/arcuser/react-arcgis/" target="_blank" rel="noopener"&gt;Using React with the ArcGIS API for JavaScript (esri.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But your Typescript definition says that view.container needs to be a HTMLDivElement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  export class DOMContainer {
    /**
     * The `id` or node representing the DOM element containing the view.
     *
     * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#container)
     */
    container: HTMLDivElement;
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While you initializer allows more options:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  interface DOMContainerProperties {
    /**
     * The `id` or node representing the DOM element containing the view.
     *
     * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#container)
     */
    container?: HTMLDivElement | string;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The workaround is to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;useEffect(() =&amp;gt; {
    ... Map initialization

    return () =&amp;gt; (view.container = null as any);
  }, []);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But i believe the Typescript definition should be updated, if this is the preferred way to cleanup.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 11:59:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/typescript-missing-undefined-for-view-container/m-p/1270311#M80618</guid>
      <dc:creator>Christer</dc:creator>
      <dc:date>2023-03-22T11:59:40Z</dc:date>
    </item>
  </channel>
</rss>

