<?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: custom widget: recommended way to pass data from action to widget.tsx in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/custom-widget-recommended-way-to-pass-data-from/m-p/1116093#M3189</link>
    <description>&lt;P&gt;I've settled on an approach of publishing the value to the widget's store w/in the Action, e.g.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;getAppStore().dispatch(appActions.widgetStatePropChange(this.widgetId, 'queryString', queryString));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then retrieving it in the widget.tsx via the props.stateProps, e.g.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&amp;lt;h2&amp;gt;{props.stateProps.queryString}&amp;lt;/h2&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has a better suggestion, I'd be glad to hear it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--john&lt;/P&gt;</description>
    <pubDate>Thu, 11 Nov 2021 19:57:10 GMT</pubDate>
    <dc:creator>john_cartwright_noaa</dc:creator>
    <dc:date>2021-11-11T19:57:10Z</dc:date>
    <item>
      <title>custom widget: recommended way to pass data from action to widget.tsx</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/custom-widget-recommended-way-to-pass-data-from/m-p/1115901#M3184</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;I have a custom widget which is listening for a Message (e.g.&amp;nbsp;&lt;SPAN&gt;DataSourceFilterChangeMessage). The logic for handling the message is in an implementation of AbstractMessageAction in the src/actions folder.&amp;nbsp; What is the recommend way to pass data captured in theAbstractMessageAction#onExecute method out to the src/runtime/widget.tsx?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;--john&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2021 01:01:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/custom-widget-recommended-way-to-pass-data-from/m-p/1115901#M3184</guid>
      <dc:creator>john_cartwright_noaa</dc:creator>
      <dc:date>2021-11-11T01:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: custom widget: recommended way to pass data from action to widget.tsx</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/custom-widget-recommended-way-to-pass-data-from/m-p/1116093#M3189</link>
      <description>&lt;P&gt;I've settled on an approach of publishing the value to the widget's store w/in the Action, e.g.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;getAppStore().dispatch(appActions.widgetStatePropChange(this.widgetId, 'queryString', queryString));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then retrieving it in the widget.tsx via the props.stateProps, e.g.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&amp;lt;h2&amp;gt;{props.stateProps.queryString}&amp;lt;/h2&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has a better suggestion, I'd be glad to hear it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--john&lt;/P&gt;</description>
      <pubDate>Thu, 11 Nov 2021 19:57:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/custom-widget-recommended-way-to-pass-data-from/m-p/1116093#M3189</guid>
      <dc:creator>john_cartwright_noaa</dc:creator>
      <dc:date>2021-11-11T19:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: custom widget: recommended way to pass data from action to widget.tsx</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/custom-widget-recommended-way-to-pass-data-from/m-p/1116856#M3199</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/532492"&gt;@john_cartwright_noaa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not really sure how you are resolving "props.stateProps.queryString" in your widget. I don't see "stateProps" in the widgets props object.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is how I am doing it (not saying that this is necessary better).&lt;/P&gt;&lt;P&gt;Sending Widget :&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.props.dispatch(appActions.widgetStatePropChange(this.props.id, 'pSearchData', cTextElements));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Receiving Widget:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;interface ExtraProps{
  pSearchData: any
}

....

export default class Widget extends React.PureComponent&amp;lt;AllWidgetProps&amp;lt;IMConfig&amp;gt; &amp;amp; ExtraProps, State&amp;gt;{
  static mapExtraStateProps = (state: IMState, ownProps: AllWidgetProps&amp;lt;IMConfig&amp;gt;): ExtraProps =&amp;gt; {
    let wId: string;
    for (const [key, value] of Object.entries(state.widgetsState)) {
      if(value.pSearchData){
        wId = key;
      }
    }
    return {
      pSearchData: state.widgetsState[wId]?.pSearchData
    }
  }
....

//Then else where in the widget code I use the extra prop
this.props.pSearchData&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 14:08:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/custom-widget-recommended-way-to-pass-data-from/m-p/1116856#M3199</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-11-15T14:08:05Z</dc:date>
    </item>
  </channel>
</rss>

