<?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 Re: [esri.views.MapView] #container element with id 'viewDiv' not found in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-views-mapview-container-element-with-id/m-p/1286522#M81072</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/681038"&gt;@mmatusova&lt;/a&gt;, I think the issue is that you are calling the js function before the div is rendered causing it not to find it. I think you can use useEffect hook for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export function MapComponent() {
    const loadMap = () =&amp;gt; {
        const map = new Map({
            basemap: "arcgis-topographic"
        });

        const view = new MapView({
            map: map,
            container: "viewDiv"
        })
    }

    useEffect(() =&amp;gt; {
        loadMap();
    }, []);

    return &amp;lt;div style={{ height: 100, width: 500 }} id='viewDiv'&amp;gt;&amp;lt;/div&amp;gt;
}&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 07 May 2023 13:31:43 GMT</pubDate>
    <dc:creator>RamaniGanason</dc:creator>
    <dc:date>2023-05-07T13:31:43Z</dc:date>
    <item>
      <title>[esri.views.MapView] #container element with id 'viewDiv' not found</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-views-mapview-container-element-with-id/m-p/1286485#M81071</link>
      <description>&lt;P&gt;Hi, I decided to try out a tutorial using the JS SDK, using React, but I am having an issue mentioned in the title.&lt;BR /&gt;The app is a simple react app made using&amp;nbsp;&lt;EM&gt;npx create-react-app my-app --template typescript.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/display-a-map/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/display-a-map/&lt;/A&gt;&amp;nbsp;The idea was to follow this tutorial.&lt;/P&gt;&lt;P&gt;I add the needed imports as so, which are:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;Map&lt;/SPAN&gt; &lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;"@arcgis/core/Map"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;MapView&lt;/SPAN&gt; &lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;"@arcgis/core/views/MapView"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;and then create a component called MapComponent, which just returns a div as such:&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;but then I end up getting the error in the title. I read that you need to set the parent's height to workaround it, but to no avail.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mmatusova_0-1683399412132.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/70032iAD57706F71FCAA72/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mmatusova_0-1683399412132.png" alt="mmatusova_0-1683399412132.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mmatusova_1-1683399433852.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/70033i4E7C3E8DE346F5DA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mmatusova_1-1683399433852.png" alt="mmatusova_1-1683399433852.png" /&gt;&lt;/span&gt;&lt;P&gt;The values and names are from the tutorial above.&lt;/P&gt;&lt;P&gt;But, if anyone has some handy tutorials for ArcGIS in React, I'd be happy to see them.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 06 May 2023 18:58:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-views-mapview-container-element-with-id/m-p/1286485#M81071</guid>
      <dc:creator>mmatusova</dc:creator>
      <dc:date>2023-05-06T18:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: [esri.views.MapView] #container element with id 'viewDiv' not found</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-views-mapview-container-element-with-id/m-p/1286522#M81072</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/681038"&gt;@mmatusova&lt;/a&gt;, I think the issue is that you are calling the js function before the div is rendered causing it not to find it. I think you can use useEffect hook for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export function MapComponent() {
    const loadMap = () =&amp;gt; {
        const map = new Map({
            basemap: "arcgis-topographic"
        });

        const view = new MapView({
            map: map,
            container: "viewDiv"
        })
    }

    useEffect(() =&amp;gt; {
        loadMap();
    }, []);

    return &amp;lt;div style={{ height: 100, width: 500 }} id='viewDiv'&amp;gt;&amp;lt;/div&amp;gt;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 07 May 2023 13:31:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-views-mapview-container-element-with-id/m-p/1286522#M81072</guid>
      <dc:creator>RamaniGanason</dc:creator>
      <dc:date>2023-05-07T13:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: [esri.views.MapView] #container element with id 'viewDiv' not found</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-views-mapview-container-element-with-id/m-p/1286523#M81073</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/609443"&gt;@RamaniGanason&lt;/a&gt;&amp;nbsp;!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ended up figuring it out later on that day fortunately, but thank you so much for confirming this is the right way to do it!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 07 May 2023 14:19:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-views-mapview-container-element-with-id/m-p/1286523#M81073</guid>
      <dc:creator>mmatusova</dc:creator>
      <dc:date>2023-05-07T14:19:36Z</dc:date>
    </item>
  </channel>
</rss>

