<?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: Create Your Own React Popup Component in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180691#M16778</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cool. I'm sure this will be helpful to me and many others. Thanks for sharing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Mar 2019 19:44:22 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2019-03-20T19:44:22Z</dc:date>
    <item>
      <title>Create Your Own React Popup Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180686#M16773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I want to combine data from multiple sources and create my own buttons using a react component. Is there an easy way to replace the out of the box&amp;nbsp;popup with a React component?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, Tyler&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2019 17:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180686#M16773</guid>
      <dc:creator>TylerWaring</dc:creator>
      <dc:date>2019-01-25T17:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create Your Own React Popup Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180687#M16774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It turns out this can be done. Create a little react component like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;import React from 'react';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;class PopUpContent extends React.Component {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;render() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;div&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;p&amp;gt;Put your rad popup content here&amp;lt;/p&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/div&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; );&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;export default PopUpContent;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then put it in the&amp;nbsp;ESRI popup like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;let puNode = document.createElement("div");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt;self.state.mapView.popup.content = puNode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt; ReactDOM.render(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;PopUp /&amp;gt;,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;puNode&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'arial black', sans-serif;"&gt; );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps someone.&amp;nbsp;&lt;/P&gt;&lt;DIV style="color: #d4d4d4; background-color: #1e1e1e; font-weight: normal; font-size: 14px;"&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jan 2019 20:21:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180687#M16774</guid>
      <dc:creator>TylerWaring</dc:creator>
      <dc:date>2019-01-28T20:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create Your Own React Popup Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180688#M16775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Tyler - I had&amp;nbsp;a similar need and your code above was extremely helpful. Thank you! One follow up question though: were you using Redux? I am new to Redux and am trying to connect my popup content component to my app's store, but I'm confused as to how you share the store across components that don't share the same root.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;W&lt;SPAN&gt;hen I first call ReactDOM.render()&amp;nbsp;&lt;/SPAN&gt;I wrap the root of&amp;nbsp;my app with redux-react's &amp;lt;Provider&amp;gt; component and pass in the store, so all of it's child components have access to the store. But because the popup content doesn't fall within the App's hierarchy and is rendered with it's own ReactDOM.render() call, it&amp;nbsp;doesn't know about the store. If you or anyone else has thoughts on how to provide access to&amp;nbsp;a Redux&amp;nbsp;store across multiple independent&amp;nbsp;React component hierarchies, let me know!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Feb 2019 23:13:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180688#M16775</guid>
      <dc:creator>NathanielRindlaub</dc:creator>
      <dc:date>2019-02-19T23:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create Your Own React Popup Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180689#M16776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Nathan,&amp;nbsp;&lt;BR /&gt;Sorry for the late reply. I haven't logged in for a while. I'm glad the code was helpful.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am not currently using redux but will be integrating it into my project. If you come up with something could you post what you get? If I end up getting the Redux store integrated I'll post it back up.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks, Tyler&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2019 19:12:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180689#M16776</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-03-20T19:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create Your Own React Popup Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180690#M16777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Tyler,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did figure out&amp;nbsp;a solution, though&amp;nbsp;I am not super confident this approach is considered best practice. I simply export&amp;nbsp;the store after it's created in index.js, and import it from index.js into my popup component and pass it to the popup tree's &amp;lt;Provider&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So index.js looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;export const store = configureStore()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;const render = () =&amp;gt; ReactDOM.render(&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;AppContainer&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Provider store={ store }&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;App history={ history } /&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Provider&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/AppContainer&amp;gt;,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;document.getElementById('root')&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;render()&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and my popup component looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import React from 'react'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;import ReactDOM from 'react-dom'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;import StreamPopup from '../../containers/StreamPopup'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;import { Provider } from 'react-redux'&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;import { store } from '../../index'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;const buildPopup = () =&amp;gt; {&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;let popupNode = document.createElement('div')&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ReactDOM.render(&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;Provider store={ store }&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;StreamPopup /&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/Provider&amp;gt;,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;popupNode&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return popupNode&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;export default buildPopup&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had trouble finding any recommendations&amp;nbsp;online about the best way to do this, which was a little surprising given the fact that &lt;A href="https://reactjs.org/docs/integrating-with-other-libraries.html#integrating-with-other-view-libraries"&gt;multiple React trees in the same app are quite common&lt;/A&gt;&amp;nbsp;and Redux is so widely used. One thing I would be a little wary of with this approach are race-conditions (if two React trees are 'racing' to&amp;nbsp;change the same state props at the same time).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe you'll have better luck than me finding a definitive solution? If you do, let me know!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2019 19:40:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180690#M16777</guid>
      <dc:creator>NathanielRindlaub</dc:creator>
      <dc:date>2019-03-20T19:40:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create Your Own React Popup Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180691#M16778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cool. I'm sure this will be helpful to me and many others. Thanks for sharing.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Mar 2019 19:44:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/180691#M16778</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2019-03-20T19:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Create Your Own React Popup Component</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/1379020#M83590</link>
      <description>&lt;P&gt;Here's a simple code snippet how we can achieve that in React v18:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (Array.isArray(testLayer.popupTemplate.content)) {
  testLayer.popupTemplate.content.unshift(
    new CustomContent({
      outFields: ['*'],
      creator: () =&amp;gt; {
        const container = document.createElement('div');
        ReactDOM.createRoot(container).render(
          &amp;lt;SomeReactButton
            title={testLayer.title}
            onClick={() =&amp;gt; setState(true)}
          /&amp;gt;
        );
        return container;
      }
    })
  );
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Creating the new root of React is just fine as described in the documentation - &lt;A href="https://react.dev/reference/react-dom/client/createRoot#createroot" target="_blank" rel="noopener"&gt;https://react.dev/reference/react-dom/client/createRoot#createroot&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; An app fully built with React will usually only have one createRoot call for its root component. A page that uses “sprinkles” of React for parts of the page may have as many separate roots as needed.&lt;/P&gt;&lt;P&gt;There are some vital disadvantages and limitations that you should be aware of:&lt;/P&gt;&lt;P&gt;- Different React roots cannot share context as they are in some sense "separate apps" (tiny frontends) - that may cause props drilling in more advanced cases;&lt;BR /&gt;- Communication between roots has to fall back on global DOM events or explicitly provided callbacks (with setter from useState for instance) - that may impede the clarity of a written code;&lt;BR /&gt;- You get less benefit from optimizations such suspense or concurrent mode;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2024 11:29:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/create-your-own-react-popup-component/m-p/1379020#M83590</guid>
      <dc:creator>BartoszStolc</dc:creator>
      <dc:date>2024-02-07T11:29:13Z</dc:date>
    </item>
  </channel>
</rss>

