devrnt / react-use-intercom

☎️ React Intercom integration without the hassle, powered by hooks.
https://devrnt.github.io/react-use-intercom/#/useIntercom
MIT License
328 stars 43 forks source link

Don't load intercom in some pages? #657

Closed imclint21 closed 2 weeks ago

imclint21 commented 9 months ago

Hi,

is it possible to don't boot intercom on some pages?

I tried somethings like this:

const forbiddenUrls = ["/purchases/create", "/products"];
return (
<IntercomProvider
  appId={INTERCOM_APP_ID}
  autoBoot
  shouldInitialize={!forbiddenUrls.includes(pathname)}>
  {children}
</IntercomProvider>
)

But it does not seems to work.

Regards

nacq commented 9 months ago

Hey @imclint21, I didn't want to load the intercom scripts in certain pages and to do so I did something very similar to your example and it is working the only difference is that I'm not using the autoBoot prop

imclint21 commented 9 months ago

Hey @imclint21, I didn't want to load the intercom scripts in certain pages and to do so I did something very similar to your example and it is working the only difference is that I'm not using the autoBoot prop

Yes so you have to manually boot in each page no?

nacq commented 9 months ago

Hey @imclint21, I didn't want to load the intercom scripts in certain pages and to do so I did something very similar to your example and it is working the only difference is that I'm not using the autoBoot prop

Yes so you have to manually boot in each page no?

Yes, that's what I'm doing. I have a wrapper component in charge of doing the boot and I'm wrapping with it the pages where I want the script to load

imclint21 commented 9 months ago

Any idea @devrnt ?

devrnt commented 6 months ago

Please provide a reproduction so I can take a look

imclint21 commented 6 months ago

Unfortunately I'll not have time, maybe I could help you tu understand what I want to achieve?

devrnt commented 2 weeks ago

See solution from @nacq https://github.com/devrnt/react-use-intercom/issues/657#issuecomment-1717718938