<?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: When we change the route in our React single-page application, the pop-up does not appear. in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/787594#M63531</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/20405"&gt;@himanshurauthan&lt;/a&gt; maybe you have another&amp;nbsp;&lt;SPAN&gt;suggestions?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Apr 2023 07:02:13 GMT</pubDate>
    <dc:creator>TZ15</dc:creator>
    <dc:date>2023-04-28T07:02:13Z</dc:date>
    <item>
      <title>When we change the route in our React single-page application, the pop-up does not appear.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/785956#M63417</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;We're encountering an issue with pop-up forms in our React project. Specifically, the pop-up form doesn't appear when we change the route dynamically. The pop-up form is supposed to appear when a certain event occurs on the page, and it works as expected when the page first loads. However, when the route is changed dynamically, the pop-up form doesn't appear at all.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;We've searched for solutions in the developer community support, but the &lt;A href="https://community.hubspot.com/t5/APIs-Integrations/Tracking-code-problem-in-Angular-Site/m-p/360261/highlight/true#M35415%20" target="_blank" rel="noopener"&gt;advice given is to reload the page&lt;/A&gt;, which isn't acceptable for our use case. We're wondering if anyone else has experienced a similar issue and if there are any alternative solutions we can try.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 07:21:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/785956#M63417</guid>
      <dc:creator>TZ15</dc:creator>
      <dc:date>2023-04-25T07:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: When we change the route in our React single-page application, the pop-up does not appear.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/785968#M63420</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/557709"&gt;@TZ15&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;It sounds like you're encountering a common issue in single-page applications where changing the route doesn't trigger a full page refresh. As a result, any event listeners or state changes that were set up on the initial page load might not be properly updated on subsequent route changes.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;One potential solution to this problem is to listen for route changes using the React Router library and explicitly trigger the pop-up form to appear when the route changes. You can do this by using the &lt;CODE&gt;useEffect&lt;/CODE&gt; hook to set up a listener for route changes, and then calling a function to show the pop-up form whenever the route changes.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here's an example of what that might look like:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;import { useEffect } from 'react';
import { useHistory } from 'react-router-dom';

function MyComponent() {
  const history = useHistory();

  useEffect(() =&amp;gt; {
    const unlisten = history.listen(() =&amp;gt; {
      // Code to show pop-up form goes here
    });

    return unlisten;
  }, [history]);

  // Rest of your component code goes here
}
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example, we're using the &lt;CODE&gt;useHistory&lt;/CODE&gt; hook from React Router to get access to the &lt;CODE&gt;history&lt;/CODE&gt; object, which allows us to listen for route changes. We then use the &lt;CODE&gt;useEffect&lt;/CODE&gt; hook to set up a listener for those route changes, and return a cleanup function to remove the listener when the component unmounts.&lt;/P&gt;
&lt;P&gt;Inside the listener function, you can add the code to show the pop-up form. You may need to adjust this code depending on how your pop-up form is implemented.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;By using this approach, you should be able to ensure that the pop-up form appears whenever the route changes, without requiring a full page refresh.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 08:14:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/785968#M63420</guid>
      <dc:creator>himanshurauthan</dc:creator>
      <dc:date>2023-04-25T08:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: When we change the route in our React single-page application, the pop-up does not appear.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/786646#M63473</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/20405"&gt;@himanshurauthan&lt;/a&gt; for your answer. I apologize if I didn't explain our situation clearly enough. Our issue is specifically related to HubSpot Forms and CTAs pop-ups not appearing when the route is changed dynamically using history.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;We've tried targeting the URL to ensure that the pop-ups appear on the correct pages, but this doesn't seem to be working when the route is changed dynamically.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-04-26 at 16.36.42.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/89907i2152422C12EFFAAE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-04-26 at 16.36.42.png" alt="Screenshot 2023-04-26 at 16.36.42.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;do you have any suggestions for how to resolve it? Thank you in advance for your help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 07:01:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/786646#M63473</guid>
      <dc:creator>TZ15</dc:creator>
      <dc:date>2023-04-28T07:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: When we change the route in our React single-page application, the pop-up does not appear.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/787594#M63531</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/20405"&gt;@himanshurauthan&lt;/a&gt; maybe you have another&amp;nbsp;&lt;SPAN&gt;suggestions?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 07:02:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/787594#M63531</guid>
      <dc:creator>TZ15</dc:creator>
      <dc:date>2023-04-28T07:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: When we change the route in our React single-page application, the pop-up does not appear.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/880088#M69101</link>
      <description>&lt;P&gt;Links to similar/identical issues, with slightly different descriptions or angles of approach:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A href="https://community.hubspot.com/t5/APIs-Integrations/Force-CTA-Scripts-to-Run-on-History-Change-for-single-page/td-p/879567" target="_blank" rel="noopener"&gt;https://community.hubspot.com/t5/APIs-Integrations/Force-CTA-Scripts-to-Run-on-History-Change-for-single-page/td-p/879567&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.hubspot.com/t5/APIs-Integrations/Tracking-code-problem-in-Angular-Site/m-p/360261" target="_blank" rel="noopener"&gt;https://community.hubspot.com/t5/APIs-Integrations/Tracking-code-problem-in-Angular-Site/m-p/360261&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.hubspot.com/t5/APIs-Integrations/pop-up-form-not-triggering-in-single-page-application/m-p/756377#M61471" target="_blank" rel="noopener"&gt;https://community.hubspot.com/t5/APIs-Integrations/pop-up-form-not-triggering-in-single-page-application/m-p/756377#M61471&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;A href="https://community.hubspot.com/t5/HubSpot-Ideas/Support-Single-Page-Application-navigation-logic-in-CTA-Beta/idi-p/806022" target="_blank"&gt;https://community.hubspot.com/t5/HubSpot-Ideas/Support-Single-Page-Application-navigation-logic-in-CTA-Beta/idi-p/806022&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 15 Nov 2023 17:29:18 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/880088#M69101</guid>
      <dc:creator>baribeau</dc:creator>
      <dc:date>2023-11-15T17:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: When we change the route in our React single-page application, the pop-up does not appear.</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/981402#M73855</link>
      <description>&lt;P&gt;I've outlined a slightly-hacky solution for this problem using Google Tag Manager and Javascript, at&amp;nbsp;&lt;A href="https://community.hubspot.com/t5/APIs-Integrations/Force-CTA-Scripts-to-Run-on-History-Change-for-single-page/m-p/977800/highlight/true#M73696" target="_blank"&gt;https://community.hubspot.com/t5/APIs-Integrations/Force-CTA-Scripts-to-Run-on-History-Change-for-single-page/m-p/977800/highlight/true#M73696&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2024 19:20:06 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/When-we-change-the-route-in-our-React-single-page-application/m-p/981402#M73855</guid>
      <dc:creator>baribeau</dc:creator>
      <dc:date>2024-05-23T19:20:06Z</dc:date>
    </item>
  </channel>
</rss>

