<?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: jimuMapView evaluating as null despite loading in 1.12 in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/jimumapview-evaluating-as-null-despite-loading-in/m-p/1308192#M7611</link>
    <description>&lt;P&gt;The loading process is actually failing at the if statement before getting to the reactiveUtils line. I have tried using whenJimuMapViewLoaded and pushing jimuMapView into state, but neither changes the behavior of the code. Removing the if statement will cause the widget to crash completely if jimuMapView === null.&lt;/P&gt;&lt;P&gt;From my further investigations, I have determined that this problem is caused by a race condition between my widget and the map widget. If my widget loads before jimuMapView, jimuMapView will evaluate as null and my widget will not fully load. Ideally, I would pull jimuMapView from props and this race condition would not be an issue. Does anyone know how to do that?&lt;BR /&gt;&lt;BR /&gt;I have a workaround involving setTimeout.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const viewManager = MapViewManager.getInstance()
const jimuMapView = viewManager.getJimuMapViewById(viewManager.getAllJimuMapViewIds()[0])
const [counter, setCounter] = useState(0)

const checkMap = () =&amp;gt; {
  if (counter &amp;gt;= 10) {
     return
  } else {
     setTimeout(() =&amp;gt; {
	console.log('from timeout')
	console.log(counter)
	setCounter(counter + 1)
     }, 1000)
   }
}

useEffect(() =&amp;gt; {
   console.log('using effect')
   console.log('jimuMapView', jimuMapView)
   if (jimuMapView) {
     console.log('jimuMapView exists')
     jimuMapView.whenJimuMapViewLoaded().then(() =&amp;gt; {
	console.log('map ready')
	setMapReady(true)
     })
   } else {
	checkMap()
   }
}, [counter])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially if jimuMapView is null, wait a second and reload the widget.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2023 12:35:35 GMT</pubDate>
    <dc:creator>JeffreyThompson2</dc:creator>
    <dc:date>2023-07-14T12:35:35Z</dc:date>
    <item>
      <title>jimuMapView evaluating as null despite loading in 1.12</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/jimumapview-evaluating-as-null-despite-loading-in/m-p/1307754#M7593</link>
      <description>&lt;P&gt;I have recently upgraded to developer edition 1.12 and I have encountered a bug which prevents one of my custom widgets from loading part of the time. I have traced the error back to jimuMapView evaluating as null despite the fact that it is actually loaded.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-07-12 142422.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75288i5182E7AC32E247A2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-07-12 142422.png" alt="Screenshot 2023-07-12 142422.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The following works 100% of the time in 1.11, but only about 75% of the time in 1.12.&amp;nbsp; My widget is loaded within a section that is not the active view when the page is loaded. The most reliable way to trigger the bug is to launch the page from the Preview in the builder mode. Reloading the Preview usually loads the widget correctly. Using the buttons within my custom widget will also clear the error and cause the rest of the widget to load correctly.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const viewManager = MapViewManager.getInstance()
const jimuMapView = viewManager.getJimuMapViewById(viewManager.getAllJimuMapViewIds()[0])

useEffect(() =&amp;gt; {
   console.log('using effect')
   console.log('jimuMapView', jimuMapView)
   if (jimuMapView) {
     console.log('jimuMapView exists')
     reactiveUtils.whenOnce(() =&amp;gt; jimuMapView.view.ready)
	.then(() =&amp;gt; {
		setMapReady(true)
	}
     )
   })
  }
}, [jimuMapView])&lt;/LI-CODE&gt;&lt;P&gt;The mapReady state variable triggers the child components which load a custom basemap gallery from the API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2023 19:57:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/jimumapview-evaluating-as-null-despite-loading-in/m-p/1307754#M7593</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-07-12T19:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: jimuMapView evaluating as null despite loading in 1.12</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/jimumapview-evaluating-as-null-despite-loading-in/m-p/1308132#M7607</link>
      <description>&lt;P&gt;In the breaking changes for 1.12 they have a &lt;A href="https://developers.arcgis.com/experience-builder/guide/whats-new/#jimumapview-and-jimulayerview" target="_self"&gt;section&lt;/A&gt; describing how to wait for the jimuMapView. I use the same method as you've described but I'm thinking I should change my code to use&amp;nbsp;&lt;A href="https://developers.arcgis.com/experience-builder/api-reference/jimu-arcgis/JimuMapView#whenJimuMapViewLoaded" target="_self"&gt;whenJimuMapViewLoaded&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 03:14:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/jimumapview-evaluating-as-null-despite-loading-in/m-p/1308132#M7607</guid>
      <dc:creator>LeonAus</dc:creator>
      <dc:date>2023-07-14T03:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: jimuMapView evaluating as null despite loading in 1.12</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/jimumapview-evaluating-as-null-despite-loading-in/m-p/1308192#M7611</link>
      <description>&lt;P&gt;The loading process is actually failing at the if statement before getting to the reactiveUtils line. I have tried using whenJimuMapViewLoaded and pushing jimuMapView into state, but neither changes the behavior of the code. Removing the if statement will cause the widget to crash completely if jimuMapView === null.&lt;/P&gt;&lt;P&gt;From my further investigations, I have determined that this problem is caused by a race condition between my widget and the map widget. If my widget loads before jimuMapView, jimuMapView will evaluate as null and my widget will not fully load. Ideally, I would pull jimuMapView from props and this race condition would not be an issue. Does anyone know how to do that?&lt;BR /&gt;&lt;BR /&gt;I have a workaround involving setTimeout.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const viewManager = MapViewManager.getInstance()
const jimuMapView = viewManager.getJimuMapViewById(viewManager.getAllJimuMapViewIds()[0])
const [counter, setCounter] = useState(0)

const checkMap = () =&amp;gt; {
  if (counter &amp;gt;= 10) {
     return
  } else {
     setTimeout(() =&amp;gt; {
	console.log('from timeout')
	console.log(counter)
	setCounter(counter + 1)
     }, 1000)
   }
}

useEffect(() =&amp;gt; {
   console.log('using effect')
   console.log('jimuMapView', jimuMapView)
   if (jimuMapView) {
     console.log('jimuMapView exists')
     jimuMapView.whenJimuMapViewLoaded().then(() =&amp;gt; {
	console.log('map ready')
	setMapReady(true)
     })
   } else {
	checkMap()
   }
}, [counter])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially if jimuMapView is null, wait a second and reload the widget.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 12:35:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/jimumapview-evaluating-as-null-despite-loading-in/m-p/1308192#M7611</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-07-14T12:35:35Z</dc:date>
    </item>
  </channel>
</rss>

