Closed arryanggaputra closed 6 years ago
I am having this issue as well. First page load, Intercom loads fine and it loads fine on every other page load.
So this is what seems to be working for me now. Basically, I force the intercom component to render client side only and in my custom document wrapper, I initiate the 'boot' event with other data depending on whether a user is logged in or not. I am going to do some more testing to make sure but initial testing showed everything working correctly.
In my App.js (my custom document wrapper):
import { IntercomAPI } from 'react-intercom' const IntercomWrapper = dynamic(import('./IntercomWrapper'), { ssr: false })
componentDidUpdate() { if(isLoggedIn()) IntercomAPI('boot', getIdTokenAttributes()) //this is how I get my user data else IntercomAPI('boot') }
...In my IntercomWrapper.js import Intercom from 'react-intercom' import config from '../config'
const IntercomWrapper = () => ( <Intercom appID={config['INTERCOM_APPID']} /> )
export default IntercomWrapper
@shauravg I already fix this by load intercom when componentDidMount()
maybe like this
{this.state.showIntercom && this._callIntercom()}
When page is loaded for the first time, intercom widget is showing on the bottom of page, but when I go to another page (SPA) Intercom widget is not showing.
I try to type this
window.Intercom
on browser console, before go to another page I got this resultBut, when I go to another page the result of
window.Intercom
isundefined
can you tell me what's wrong on here?