<?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 Widget Cleanup Throws Error in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-cleanup-throws-error/m-p/1024008#M71666</link>
    <description>&lt;P&gt;Following this guide: &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/featurefilter-attributes/" target="_self"&gt;Feature Filters&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;When moving to another route (react) or effectively "cleaning up", I get thrown the following error in console.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;If I remove the line of code `&lt;SPAN&gt;view&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ui&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;add&lt;/SPAN&gt;&lt;SPAN&gt;(filterExpand, &lt;/SPAN&gt;&lt;SPAN&gt;"top-left"&lt;/SPAN&gt;&lt;SPAN&gt;);` then I have no issues. I am not sure what I am doing wrong, because the guide above has no explicit cleanup.&lt;BR /&gt;&lt;BR /&gt;My code:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const Map = (props: any) =&amp;gt; {
  const classes = useStyles();
  const mapDiv = useRef(null);

  useEffect(() =&amp;gt; {
    if (mapDiv.current) {
      const filterStuff = (stuff: any, view: any) =&amp;gt; {
        const data = stuff.getAttribute("data-stuff");

        // const test =
        view.filter = new FeatureFilter({
          where: `stuff='${data}'`
        })

        props.handleStuff(data);
      }

      const renderer = ...

      const geoJSONLayer = new GeoJSONLayer({
        url: ...,
        renderer: renderer,
        outFields: ["*"]
      });

      const map = new ArcGISMap({
        basemap: "topo",
        ground: "world-elevation",
        layers: [geoJSONLayer]
      });

      const view: any = new SceneView({
        container: mapDiv.current!,
        map: map,
        camera: {
          position: {
            ...
          },
          tilt: 0
        }
      });

      const filterElement = document.getElementById("stuff-filter");

      view.whenLayerView(geoJSONLayer).then(function(layerView: any) {
        // set up UI items
        if (filterElement) {
          filterElement.addEventListener("click", function(event) {
            filterStuff(event.target, layerView);
          });
          filterElement.style.visibility = "visible";
          const filterExpand = new Expand({
            view: view,
            content: filterElement,
            expandIconClass: "esri-icon-filter",
            group: "top-left"
          });
          //clear the filters when user closes the expand widget
          filterExpand.watch("expanded", function () {
            if (!filterExpand.expanded) {
              layerView.filter = null;
              props.handleStuff(null);
            }
          });
          view.ui.add(filterExpand, "top-left");
        }
      });
    }
  }, []);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;div id="stuff-filter" className={classes.filter}&amp;gt;
        {items.map((item, index) =&amp;gt; (
          &amp;lt;div className={`FilterItem ${classes.filterItem}`} data-stuff={item}&amp;gt;{item}&amp;lt;/div&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
      &amp;lt;div className={classes.mapImage} ref={mapDiv}&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Feb 2021 19:51:27 GMT</pubDate>
    <dc:creator>developerarce</dc:creator>
    <dc:date>2021-02-05T19:51:27Z</dc:date>
    <item>
      <title>Widget Cleanup Throws Error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-cleanup-throws-error/m-p/1024008#M71666</link>
      <description>&lt;P&gt;Following this guide: &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/featurefilter-attributes/" target="_self"&gt;Feature Filters&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;When moving to another route (react) or effectively "cleaning up", I get thrown the following error in console.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;If I remove the line of code `&lt;SPAN&gt;view&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ui&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;add&lt;/SPAN&gt;&lt;SPAN&gt;(filterExpand, &lt;/SPAN&gt;&lt;SPAN&gt;"top-left"&lt;/SPAN&gt;&lt;SPAN&gt;);` then I have no issues. I am not sure what I am doing wrong, because the guide above has no explicit cleanup.&lt;BR /&gt;&lt;BR /&gt;My code:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const Map = (props: any) =&amp;gt; {
  const classes = useStyles();
  const mapDiv = useRef(null);

  useEffect(() =&amp;gt; {
    if (mapDiv.current) {
      const filterStuff = (stuff: any, view: any) =&amp;gt; {
        const data = stuff.getAttribute("data-stuff");

        // const test =
        view.filter = new FeatureFilter({
          where: `stuff='${data}'`
        })

        props.handleStuff(data);
      }

      const renderer = ...

      const geoJSONLayer = new GeoJSONLayer({
        url: ...,
        renderer: renderer,
        outFields: ["*"]
      });

      const map = new ArcGISMap({
        basemap: "topo",
        ground: "world-elevation",
        layers: [geoJSONLayer]
      });

      const view: any = new SceneView({
        container: mapDiv.current!,
        map: map,
        camera: {
          position: {
            ...
          },
          tilt: 0
        }
      });

      const filterElement = document.getElementById("stuff-filter");

      view.whenLayerView(geoJSONLayer).then(function(layerView: any) {
        // set up UI items
        if (filterElement) {
          filterElement.addEventListener("click", function(event) {
            filterStuff(event.target, layerView);
          });
          filterElement.style.visibility = "visible";
          const filterExpand = new Expand({
            view: view,
            content: filterElement,
            expandIconClass: "esri-icon-filter",
            group: "top-left"
          });
          //clear the filters when user closes the expand widget
          filterExpand.watch("expanded", function () {
            if (!filterExpand.expanded) {
              layerView.filter = null;
              props.handleStuff(null);
            }
          });
          view.ui.add(filterExpand, "top-left");
        }
      });
    }
  }, []);

  return (
    &amp;lt;&amp;gt;
      &amp;lt;div id="stuff-filter" className={classes.filter}&amp;gt;
        {items.map((item, index) =&amp;gt; (
          &amp;lt;div className={`FilterItem ${classes.filterItem}`} data-stuff={item}&amp;gt;{item}&amp;lt;/div&amp;gt;
        ))}
      &amp;lt;/div&amp;gt;
      &amp;lt;div className={classes.mapImage} ref={mapDiv}&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;/&amp;gt;
  );
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 19:51:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-cleanup-throws-error/m-p/1024008#M71666</guid>
      <dc:creator>developerarce</dc:creator>
      <dc:date>2021-02-05T19:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Widget Cleanup Throws Error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-cleanup-throws-error/m-p/1024021#M71668</link>
      <description>&lt;P&gt;Solution:&lt;BR /&gt;&lt;BR /&gt;Before&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;&amp;gt;
  &amp;lt;div id="stuff-filter" className={classes.filter}&amp;gt;
        {items.map((item, index) =&amp;gt; (
          &amp;lt;div className={`FilterItem ${classes.filterItem}`} data-stuff={item}&amp;gt;{item}&amp;lt;/div&amp;gt;
        ))}
  &amp;lt;/div&amp;gt;
  &amp;lt;div className={classes.mapImage} ref={mapDiv}&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;After&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;&amp;gt;
  &amp;lt;div className={classes.mapImage} ref={mapDiv}&amp;gt;
    &amp;lt;div id="stuff-filter" className={classes.filter}&amp;gt;
        {items.map((item, index) =&amp;gt; (
          &amp;lt;div className={`FilterItem ${classes.filterItem}`} data-stuff={item}&amp;gt;{item}&amp;lt;/div&amp;gt;
        ))}
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Feb 2021 20:03:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/widget-cleanup-throws-error/m-p/1024021#M71668</guid>
      <dc:creator>developerarce</dc:creator>
      <dc:date>2021-02-05T20:03:01Z</dc:date>
    </item>
  </channel>
</rss>

