<?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: How can I get a custom widget to rerender when fields change in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324024#M82116</link>
    <description>&lt;P&gt;Also in the docs they mention it's not recommended to extend Widget but if I don't it won't render at all except inside an expandable&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2023 18:10:31 GMT</pubDate>
    <dc:creator>GBreen</dc:creator>
    <dc:date>2023-08-30T18:10:31Z</dc:date>
    <item>
      <title>How can I get a custom widget to rerender when fields change</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324023#M82115</link>
      <description>&lt;P&gt;I've got a simple widget that toggles a boolean but it stays on false and never rerenders. What am I doing wrong?&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;LI-CODE lang="javascript"&gt;import { property } from 'esri/core/accessorSupport/decorators';
import { tsx } from 'esri/widgets/support/widget';
import esriWidget = require('esri/widgets/Widget');

const CSS = {
	base: 'redline-widget esri-widget--panel esri-widget',
	button: 'btn btn-white btn-sm btn-primary pull-right',
	loading: 'esri-icon-loading-indicator esri-rotating'
};

class Test extends esriWidget {
	constructor(config: any) {
		super();

		setInterval(() =&amp;gt; {
			this.processing = !this.processing;
		}, 5000);
	}

	@property()
	processing: boolean;

	render() {
		return (
			&amp;lt;div class={CSS.base}&amp;gt;
				{this.processing ? "True" : "False"}
			&amp;lt;/div&amp;gt;
		);
	}
}

export = Test;&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;</description>
      <pubDate>Wed, 30 Aug 2023 18:09:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324023#M82115</guid>
      <dc:creator>GBreen</dc:creator>
      <dc:date>2023-08-30T18:09:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a custom widget to rerender when fields change</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324024#M82116</link>
      <description>&lt;P&gt;Also in the docs they mention it's not recommended to extend Widget but if I don't it won't render at all except inside an expandable&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 18:10:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324024#M82116</guid>
      <dc:creator>GBreen</dc:creator>
      <dc:date>2023-08-30T18:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a custom widget to rerender when fields change</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324083#M82117</link>
      <description>&lt;P&gt;We no longer recommend you extend the Widget class or build custom widgets with the Widget base.&lt;/P&gt;&lt;P&gt;It's recommended you use your preferred framework to build your components as shown here.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/jsapi-resources/tree/main/esm-samples/jsapi-custom-ui" target="_blank"&gt;https://github.com/Esri/jsapi-resources/tree/main/esm-samples/jsapi-custom-ui&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you however, need to maintain a current widget, you need to use the subclass decorator to make reactivity work as show &lt;A href="https://github.com/odoe/jsapi-ts-esm-widget/blob/main/src/widget.tsx" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 20:10:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324083#M82117</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2023-08-30T20:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a custom widget to rerender when fields change</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324089#M82118</link>
      <description>&lt;P&gt;Yeah I'm trying to maintain and upgrade a suite of existing widgets but if I add a subclass to this widget like you suggest I get an error "&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;TypeError: &lt;SPAN class=""&gt;class constructors must be invoked with 'new'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;" when trying to create the widget:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return new TestWidget();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions on that?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 20:17:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324089#M82118</guid>
      <dc:creator>GBreen</dc:creator>
      <dc:date>2023-08-30T20:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a custom widget to rerender when fields change</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324111#M82119</link>
      <description>&lt;P&gt;It might be your tsconfig settings too. This project works, see if it can help you out.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/odoe/jsapi-ts-esm-widget" target="_blank"&gt;https://github.com/odoe/jsapi-ts-esm-widget&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 20:36:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324111#M82119</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2023-08-30T20:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a custom widget to rerender when fields change</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324160#M82120</link>
      <description>&lt;P&gt;This looks like a scope issue.&amp;nbsp; In your anonymous function called by setInterval, "this" will refer to the &lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/Window" target="_self"&gt;window&lt;/A&gt;, not the instance of the widget.&amp;nbsp; You should be able to get around this using &lt;A href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Function/bind" target="_self"&gt;bind&lt;/A&gt;:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;window.setInterval(function() {
	this.processing = !this.processing;
}.bind(this), 5000);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 22:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324160#M82120</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-08-30T22:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get a custom widget to rerender when fields change</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324170#M82121</link>
      <description>&lt;P&gt;I just noticed you're using the "esri/" paths, so you must be using the AMD CDN.&lt;/P&gt;&lt;P&gt;In that case, I don't think you can use the 'extends', you need to use createSubclass.&lt;/P&gt;&lt;P&gt;The snippets here provide a dropdown to switch between TS and JS, and you can see what I mean.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/implementing-accessor/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/implementing-accessor/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ReneRubalcava_0-1693435642925.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/79523i9FD967CFBC878C16/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ReneRubalcava_0-1693435642925.png" alt="ReneRubalcava_0-1693435642925.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I haven't built custom widgets in this pattern, so not entirely sure, but that might be the way to go.&lt;/P&gt;&lt;P&gt;I did update my ESM widget sample with your code and it does work, so I think it's the createSubclass you need.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/odoe/jsapi-ts-esm-widget/blob/main/src/test-widget.tsx" target="_blank"&gt;https://github.com/odoe/jsapi-ts-esm-widget/blob/main/src/test-widget.tsx&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 22:51:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-get-a-custom-widget-to-rerender-when/m-p/1324170#M82121</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2023-08-30T22:51:13Z</dc:date>
    </item>
  </channel>
</rss>

