<?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 to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1261853#M80387</link>
    <description>&lt;P&gt;You can use React Portals for using React components in your Popup.&lt;/P&gt;&lt;P&gt;Here's a &lt;A href="https://odoe.net/blog/popup-react-portals" target="_blank" rel="noopener"&gt;blog post&lt;/A&gt; on the topic.&lt;/P&gt;&lt;P&gt;It will walk you through the steps for something like this.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { useEffect } from "react";
import { createPortal } from "react-dom";

const PopupPortal = ({ mountNode, children }) =&amp;gt; {
  const el = document.createElement("div");

  useEffect(() =&amp;gt; {
    mountNode.appendChild(el);
    return () =&amp;gt; mountNode.removeChild(el);
  }, [el, mountNode]);

  return createPortal(children, el);
};

export default PopupPortal;&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 26 Feb 2023 18:07:52 GMT</pubDate>
    <dc:creator>ReneRubalcava</dc:creator>
    <dc:date>2023-02-26T18:07:52Z</dc:date>
    <item>
      <title>How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1261827#M80384</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a React Functional Component. I would like to use this to show in PopUp in JS API 4.X ReactJS based application. I am using React V 17.0. The content from functional component is shown as html string but it is not rendered as html content.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Vara_PrasadM_S_0-1677398200104.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63735i0B54439C59B3F163/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Vara_PrasadM_S_0-1677398200104.png" alt="Vara_PrasadM_S_0-1677398200104.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My code snippet:&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;let customContent = new CustomContent({ outFields: ["*"],creator: () =&amp;gt; {
const div = document.createElement('div');
ReactDOM.render(&amp;lt;PopUpContent/&amp;gt;, div);
return div;
}
});
const template = new PopupTemplate({
				     outFields: ["*"],
				     title: " ",
				     content: [customContent]
				  });
layerObj.popupTemplate = template;
					 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has any suggestion, please let me know.&lt;/P&gt;&lt;P&gt;Thank you very much in advance!&lt;/P&gt;&lt;P&gt;With Regards,&lt;/P&gt;&lt;P&gt;Vara Prasad&lt;/P&gt;</description>
      <pubDate>Sun, 26 Feb 2023 08:08:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1261827#M80384</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2023-02-26T08:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1261853#M80387</link>
      <description>&lt;P&gt;You can use React Portals for using React components in your Popup.&lt;/P&gt;&lt;P&gt;Here's a &lt;A href="https://odoe.net/blog/popup-react-portals" target="_blank" rel="noopener"&gt;blog post&lt;/A&gt; on the topic.&lt;/P&gt;&lt;P&gt;It will walk you through the steps for something like this.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { useEffect } from "react";
import { createPortal } from "react-dom";

const PopupPortal = ({ mountNode, children }) =&amp;gt; {
  const el = document.createElement("div");

  useEffect(() =&amp;gt; {
    mountNode.appendChild(el);
    return () =&amp;gt; mountNode.removeChild(el);
  }, [el, mountNode]);

  return createPortal(children, el);
};

export default PopupPortal;&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 26 Feb 2023 18:07:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1261853#M80387</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2023-02-26T18:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1261911#M80389</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384" target="_self"&gt;&lt;SPAN class=""&gt;ReneRubalcava,&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for your help. Thank you for the blog and details. I tried to implement this. However, its re loading the whole page when ever I try to open the mapview's popup and not loading any popup. I am still trying to fix it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Vara Prasad&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 06:59:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1261911#M80389</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2023-02-27T06:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1319467#M82001</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/129432"&gt;@Vara_PrasadM_S&lt;/a&gt;, did you find any solution?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 06:48:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1319467#M82001</guid>
      <dc:creator>LuisSolaRuiz</dc:creator>
      <dc:date>2023-08-17T06:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1339518#M82511</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/702943"&gt;@LuisSolaRuiz&lt;/a&gt;&amp;nbsp;, Sorry for late reply. Could not solve it. So, I coded to construct html string with required css and used that as content. Could not implement as custom component.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2023 12:28:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1339518#M82511</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2023-10-19T12:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1405714#M84226</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/129432"&gt;@Vara_PrasadM_S&lt;/a&gt;&amp;nbsp;. Sry for the late response. I find a way to include custom React Components inside esri pop up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if you need it. Regards&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2024 13:48:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1405714#M84226</guid>
      <dc:creator>LuisSolaRuiz</dc:creator>
      <dc:date>2024-04-04T13:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1408869#M84298</link>
      <description>&lt;P&gt;Hi, can you please let me know how you did this? Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 02:04:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1408869#M84298</guid>
      <dc:creator>DevinEPA</dc:creator>
      <dc:date>2024-04-12T02:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1408969#M84301</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/702943"&gt;@LuisSolaRuiz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;That's amazing. Could you please explain how we can achieve this. Thanks in advance.&lt;/P&gt;&lt;P&gt;With Regards,&lt;/P&gt;&lt;P&gt;Vara Prasad&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 13:53:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1408969#M84301</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2024-04-12T13:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1410767#M84359</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/129432"&gt;@Vara_PrasadM_S&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/671883"&gt;@DevinEPA&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, of course. In the layer you want to include the custom component you have to use the attribute&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;popupTemplate &lt;/STRONG&gt;adding the &lt;STRONG&gt;content&lt;/STRONG&gt; attribute&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-popup-content-CustomContent.html" target="_blank" rel="noopener"&gt;customContent&lt;/A&gt; by esri. Then, create a &lt;STRONG&gt;div&lt;/STRONG&gt; in the document where your component will render and thanks to &lt;STRONG&gt;root.render&lt;/STRONG&gt;, load your component and return the created &lt;STRONG&gt;div&lt;/STRONG&gt;. For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;popupTemplate: {
    content: [
        new CustomContent({
            outFields: ['*'],
            creator: (event) =&amp;gt; {
                const div = document.createElement('div');
                if (event) {
                    const { title } = event.graphic.attributes;
                    const { description } = event.graphic.attributes;

                    const root = createRoot(div);
                    root.render(
                        &amp;lt;MapPopup
                            title={title}
                            description={description}
                        /&amp;gt;,
                    );
                }
                return div;
            },
        }),
    ],&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Probably you want to customise more your modal, you can do it via css and some properties inside the view to hide some elements, like:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;popup: {
    dockOptions: {
        buttonEnabled: false,
    },
    visibleElements: {
        featureNavigation: false,
        closeButton: false,
    },
    viewModel: {
        includeDefaultActions: false,
    },
},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I hope this can solve your doubts!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 06:53:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1410767#M84359</guid>
      <dc:creator>LuisSolaRuiz</dc:creator>
      <dc:date>2024-04-17T06:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use ReactJS Functional component for CustomContent in PopUpTemplate in JS API 4.X</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1413423#M84391</link>
      <description>&lt;P&gt;Thank you very much&amp;nbsp;&lt;A href="https://community.esri.com/t5/user/viewprofilepage/user-id/702943" target="_blank"&gt;@LuisSolaRuiz.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 10:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-use-reactjs-functional-component-for/m-p/1413423#M84391</guid>
      <dc:creator>Vara_PrasadM_S</dc:creator>
      <dc:date>2024-04-22T10:53:02Z</dc:date>
    </item>
  </channel>
</rss>

