<?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 Adding a widget to the outside of a map div in react in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-widget-to-the-outside-of-a-map-div-in/m-p/1420292#M84525</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying put a search widget into a sidebar in my project app, but am running into some issues.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issues I'm seeing:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;when trying to render the &lt;A href="https://github.com/clintonlunn/arcgis-react-template/blob/main/src/components/SearchBar.tsx" target="_self"&gt;SearchBar&lt;/A&gt; in my &lt;A href="https://github.com/clintonlunn/arcgis-react-template/blob/main/src/components/Toolbar.tsx" target="_self"&gt;Toolbar&lt;/A&gt; component, the search widget seems to get correctly created but never appears in my sidebar.&lt;/LI&gt;&lt;LI&gt;if I put the SearchBar into the &lt;A href="https://github.com/clintonlunn/arcgis-react-template/blob/main/src/components/Header.tsx" target="_self"&gt;Header&lt;/A&gt; component (not a lazy loaded component), it works on page load, but if I save the SearchBar file again, the search bar disappears. See below for how I am implementing the SearchBar.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I've created a github repo to illustrate issues I am seeing.&amp;nbsp;&lt;A href="https://github.com/clintonlunn/arcgis-react-template" target="_blank" rel="noopener"&gt;https://github.com/clintonlunn/arcgis-react-template&lt;/A&gt;. Any suggestions would be much appreciated.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import Search from "@arcgis/core/widgets/Search.js";
import React, { useContext, useEffect, useRef } from "react";
import { MapContext } from "../contexts/MapProvider";

function SearchBar() {
  const { view } = useContext(MapContext);
  const searchDivRef = useRef&amp;lt;HTMLDivElement | null&amp;gt;(null);

  useEffect(() =&amp;gt; {
    let searchWidget: __esri.widgetsSearch;
    if (view &amp;amp;&amp;amp; searchDivRef.current) {
      console.log("Creating search widget");
      console.log("View:", view);

      searchWidget = new Search({
        view: view,
        sources: [],
        container: searchDivRef.current,
      });

      console.log("Search widget:", searchWidget);
    } else {
      console.log("View or searchDivRef.current is not available");
    }

    return () =&amp;gt; {
      if (searchWidget &amp;amp;&amp;amp; searchWidget.destroy) {
        searchWidget.destroy();
      }
    }
  }, [view]);

  return &amp;lt;div ref={searchDivRef}&amp;gt;&amp;lt;/div&amp;gt;;

}

export default SearchBar;&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;Thank you,&lt;/P&gt;&lt;P&gt;Clinton&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2024 14:56:44 GMT</pubDate>
    <dc:creator>ClintonLunnUGS</dc:creator>
    <dc:date>2024-05-08T14:56:44Z</dc:date>
    <item>
      <title>Adding a widget to the outside of a map div in react</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-widget-to-the-outside-of-a-map-div-in/m-p/1420292#M84525</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying put a search widget into a sidebar in my project app, but am running into some issues.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Issues I'm seeing:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;when trying to render the &lt;A href="https://github.com/clintonlunn/arcgis-react-template/blob/main/src/components/SearchBar.tsx" target="_self"&gt;SearchBar&lt;/A&gt; in my &lt;A href="https://github.com/clintonlunn/arcgis-react-template/blob/main/src/components/Toolbar.tsx" target="_self"&gt;Toolbar&lt;/A&gt; component, the search widget seems to get correctly created but never appears in my sidebar.&lt;/LI&gt;&lt;LI&gt;if I put the SearchBar into the &lt;A href="https://github.com/clintonlunn/arcgis-react-template/blob/main/src/components/Header.tsx" target="_self"&gt;Header&lt;/A&gt; component (not a lazy loaded component), it works on page load, but if I save the SearchBar file again, the search bar disappears. See below for how I am implementing the SearchBar.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I've created a github repo to illustrate issues I am seeing.&amp;nbsp;&lt;A href="https://github.com/clintonlunn/arcgis-react-template" target="_blank" rel="noopener"&gt;https://github.com/clintonlunn/arcgis-react-template&lt;/A&gt;. Any suggestions would be much appreciated.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import Search from "@arcgis/core/widgets/Search.js";
import React, { useContext, useEffect, useRef } from "react";
import { MapContext } from "../contexts/MapProvider";

function SearchBar() {
  const { view } = useContext(MapContext);
  const searchDivRef = useRef&amp;lt;HTMLDivElement | null&amp;gt;(null);

  useEffect(() =&amp;gt; {
    let searchWidget: __esri.widgetsSearch;
    if (view &amp;amp;&amp;amp; searchDivRef.current) {
      console.log("Creating search widget");
      console.log("View:", view);

      searchWidget = new Search({
        view: view,
        sources: [],
        container: searchDivRef.current,
      });

      console.log("Search widget:", searchWidget);
    } else {
      console.log("View or searchDivRef.current is not available");
    }

    return () =&amp;gt; {
      if (searchWidget &amp;amp;&amp;amp; searchWidget.destroy) {
        searchWidget.destroy();
      }
    }
  }, [view]);

  return &amp;lt;div ref={searchDivRef}&amp;gt;&amp;lt;/div&amp;gt;;

}

export default SearchBar;&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;Thank you,&lt;/P&gt;&lt;P&gt;Clinton&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 14:56:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-widget-to-the-outside-of-a-map-div-in/m-p/1420292#M84525</guid>
      <dc:creator>ClintonLunnUGS</dc:creator>
      <dc:date>2024-05-08T14:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a widget to the outside of a map div in react</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-widget-to-the-outside-of-a-map-div-in/m-p/1641382#M87508</link>
      <description>&lt;P&gt;I'd love to see a response to this as well. Currently trying to do something similar.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm trying to build a custom directions component that is going to hit a pgRouting service, but I want to grab the data from the esri geocoder search source.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Search Widget -&amp;gt; get address from input -&amp;gt; push lat, lng to the start and stop -&amp;gt; refresh view in postgres to create route.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2025 20:23:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-widget-to-the-outside-of-a-map-div-in/m-p/1641382#M87508</guid>
      <dc:creator>geo_sunriver</dc:creator>
      <dc:date>2025-08-12T20:23:27Z</dc:date>
    </item>
  </channel>
</rss>

