<?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: Problem Implementing MutableStoreManager in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1414409#M12255</link>
    <description>&lt;P&gt;Thank you, this helped me figure out that I was passing the id of the sending widget, not the receiving widget. Once I fixed that, it worked. For whatever reason, passing simple objects via widgetStatePropChange doesn't seem to care about which widget ID you use.&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2024 20:29:25 GMT</pubDate>
    <dc:creator>ChrisCarter3</dc:creator>
    <dc:date>2024-04-23T20:29:25Z</dc:date>
    <item>
      <title>Problem Implementing MutableStoreManager</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1411906#M12165</link>
      <description>&lt;P&gt;Hoping someone can help me figure out what I'm doing wrong. I've been struggling to figure this out all week.&lt;/P&gt;&lt;P&gt;I'm trying to pass complex objects (in this case an Extent) between widgets.&lt;/P&gt;&lt;P&gt;In the sender widget, I'm using this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;MutableStoreManager&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getInstance&lt;/SPAN&gt;&lt;SPAN&gt;().&lt;/SPAN&gt;&lt;SPAN&gt;updateStateValue&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;id&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'searchExtent'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;ext&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 the receiving widget has this in the mapExtraStateProps function:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;newSearchExtent&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;props&lt;/SPAN&gt;&lt;SPAN&gt;?.&lt;/SPAN&gt;&lt;SPAN&gt;mutableStateProps&lt;/SPAN&gt;&lt;SPAN&gt;?.&lt;/SPAN&gt;&lt;SPAN&gt;searchExtent&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;But it always comes back as undefined.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Has anyone successfully passed complex JavaScript objects between widgets?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 18 Apr 2024 21:31:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1411906#M12165</guid>
      <dc:creator>ChrisCarter3</dc:creator>
      <dc:date>2024-04-18T21:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Implementing MutableStoreManager</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1412212#M12171</link>
      <description>&lt;P&gt;Your syntax looks ok. The ? after props is unnecessary, but I don't think it will make a difference.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Will not error
const newSearchExtent = props.mutableStateProps?.searchExtent;&lt;/LI-CODE&gt;&lt;P&gt;I assume id in&amp;nbsp;&lt;SPAN&gt;MutableStoreManager&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getInstance&lt;/SPAN&gt;&lt;SPAN&gt;().&lt;/SPAN&gt;&lt;SPAN&gt;updateStateValue&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;id&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;'searchExtent'&lt;/SPAN&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;ext&lt;/SPAN&gt;&lt;SPAN&gt;); is passing a string value like 'widget_7' where 7 is the correct id number of the receiving widget.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Confirm that ext in the sending widget is correctly defined.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I suspect the problem is that the message is being sent multiple times because of re-renders and you are only catching an undefined instance. What happens if you try to read your message in a useEffect() function?&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;useEffect(() =&amp;gt; {
   console.log(props.mutableStateProps?.searchExtent)
}, [props.mutableStateProps?.searchExtent])&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Apr 2024 12:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1412212#M12171</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2024-04-19T12:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Implementing MutableStoreManager</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1412271#M12174</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/380846"&gt;@ChrisCarter3&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hoping someone can help me figure out what I'm doing wrong. I've been struggling to figure this out all week.&lt;/P&gt;&lt;P&gt;I'm trying to pass complex objects (in this case an Extent) between widgets.&lt;/P&gt;&lt;P&gt;In the sender widget, I'm using this:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;MutableStoreManager&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getInstance&lt;/SPAN&gt;&lt;SPAN&gt;().&lt;/SPAN&gt;&lt;SPAN&gt;updateStateValue&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;id&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;'searchExtent'&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;ext&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 the receiving widget has this in the mapExtraStateProps function:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;newSearchExtent&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;props&lt;/SPAN&gt;&lt;SPAN&gt;?.&lt;/SPAN&gt;&lt;SPAN&gt;mutableStateProps&lt;/SPAN&gt;&lt;SPAN&gt;?.&lt;/SPAN&gt;&lt;SPAN&gt;searchExtent&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;But it always comes back as undefined.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Has anyone successfully passed complex JavaScript objects between widgets?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;passed complex JavaScript objects between widgets&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;This is a question i find my self asking periodically, because when you build a tsx file and then use it in another you are technically passing data between them.&amp;nbsp; The two caveats you have to watch out for are the following:&lt;BR /&gt;&lt;BR /&gt;Props are defined from the highest component on down.&amp;nbsp; If you update something inside a widget, but don't use a callback or event handler that is defined on the parent and passed into the child the parent props may not know about it. Otherwise it is possible the parent might not be aware.&lt;BR /&gt;&lt;BR /&gt;Below is a very generic example of what this may look like.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// ParentComponent.js
import React, { useState } from 'react';
import ChildComponent from './ChildComponent';

function ParentComponent() {
  const [data, setData] = useState('initial data');

  const handleDataChange = (newData) =&amp;gt; {
    setData(newData);
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;ChildComponent data={data} onDataChange={handleDataChange} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default ParentComponent;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// ChildComponent.js
import React from 'react';

function ChildComponent({ data, onDataChange }) {
  const handleClick = () =&amp;gt; {
    // Modify the data
    const newData = 'modified data';
    
    // Call the callback function to pass the modified data to the parent
    onDataChange(newData);
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;button onClick={handleClick}&amp;gt;Modify Data&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default ChildComponent;&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;State does not necessarily have a guarantee on when it is correct. I find I often have to add a check to see if something is loaded, before other processes can handle and render output.&amp;nbsp; In functional components you may need a useEffect to manage when these update too.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 14:20:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1412271#M12174</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2024-04-19T14:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem Implementing MutableStoreManager</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1414409#M12255</link>
      <description>&lt;P&gt;Thank you, this helped me figure out that I was passing the id of the sending widget, not the receiving widget. Once I fixed that, it worked. For whatever reason, passing simple objects via widgetStatePropChange doesn't seem to care about which widget ID you use.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 20:29:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/problem-implementing-mutablestoremanager/m-p/1414409#M12255</guid>
      <dc:creator>ChrisCarter3</dc:creator>
      <dc:date>2024-04-23T20:29:25Z</dc:date>
    </item>
  </channel>
</rss>

