<?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: use of 'this' in the class component in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/use-of-this-in-the-class-component/m-p/1244660#M5973</link>
    <description>&lt;P&gt;You can use an arrow function in the callback, this will auto bind the outer scope to the inner scope, kind of like what the old lang.hitch used to do in Web AppBuilder development.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;this.props.mapView.whenLayerView(layer).then((layerView) =&amp;gt; {
        layerView.watch("updating", (val) =&amp;gt; {
          // wait for the layer view to finish updating
          if (!val) {
            layerView.queryExtent().then((response)=&amp;gt; {
              // go to the extent of all the graphics in the layer view
              this.props.mapView.goTo(response.extent);
            });
          }
        });
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've not tested the above, but I think it should work, if not ping me back. The other thing to consider is pushing your callbacks out in to seperate functions as it make the code easier to test, if you're running unit tests etc.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Dec 2022 21:58:55 GMT</pubDate>
    <dc:creator>Grant-S-Carroll</dc:creator>
    <dc:date>2022-12-30T21:58:55Z</dc:date>
    <item>
      <title>use of 'this' in the class component</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/use-of-this-in-the-class-component/m-p/1244598#M5971</link>
      <description>&lt;P&gt;I am trying to use this script from the &lt;A href="https://swaggypyang.github.io/arcgisapi/sdk/latest/sample-code/featurelayer-queryextent/index.html" target="_self"&gt;ArcGIS JS API&lt;/A&gt; to zoom in for a client-side feature layer. However, I get the error on line 7 due to the 'this' keyword. The prop is necessary since I am referring to the view from another module as suggested from&amp;nbsp;another &lt;A href="https://community.esri.com/t5/arcgis-experience-builder-questions/passing-on-map-properties-from-the-parent-to-the/m-p/1235742#M5829" target="_self"&gt;posting&lt;/A&gt;. The error is related to the&amp;nbsp; 'this'&amp;nbsp; in a class component. I tried to bind the goTo&amp;nbsp; &amp;nbsp;but didn't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/1104" target="_blank" rel="noopener"&gt;@RobertScheitlin__GISP&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;,&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/404038" target="_blank" rel="noopener"&gt;@Grant-S-Carroll&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;or anyone else? Thank you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.props.mapView.goTo(response.extent).bind(this);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LefterisKoumis_0-1672420766863.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59549iECB53A45DE738CD6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LefterisKoumis_0-1672420766863.png" alt="LefterisKoumis_0-1672420766863.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.props.mapView.whenLayerView(layer).then(function (layerView) {
        layerView.watch("updating", function (val) {
          // wait for the layer view to finish updating
          if (!val) {
            layerView.queryExtent().then(function (response) {
              // go to the extent of all the graphics in the layer view
              this.props.mapView.goTo(response.extent);
            });
          }
        });
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 17:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/use-of-this-in-the-class-component/m-p/1244598#M5971</guid>
      <dc:creator>LefterisKoumis</dc:creator>
      <dc:date>2022-12-30T17:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: use of 'this' in the class component</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/use-of-this-in-the-class-component/m-p/1244660#M5973</link>
      <description>&lt;P&gt;You can use an arrow function in the callback, this will auto bind the outer scope to the inner scope, kind of like what the old lang.hitch used to do in Web AppBuilder development.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;this.props.mapView.whenLayerView(layer).then((layerView) =&amp;gt; {
        layerView.watch("updating", (val) =&amp;gt; {
          // wait for the layer view to finish updating
          if (!val) {
            layerView.queryExtent().then((response)=&amp;gt; {
              // go to the extent of all the graphics in the layer view
              this.props.mapView.goTo(response.extent);
            });
          }
        });
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've not tested the above, but I think it should work, if not ping me back. The other thing to consider is pushing your callbacks out in to seperate functions as it make the code easier to test, if you're running unit tests etc.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 21:58:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/use-of-this-in-the-class-component/m-p/1244660#M5973</guid>
      <dc:creator>Grant-S-Carroll</dc:creator>
      <dc:date>2022-12-30T21:58:55Z</dc:date>
    </item>
  </channel>
</rss>

