Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"TypeError: window.Intercom is not a function" after react 16 upgrade #41

Closed
llaurila opened this issue Dec 27, 2017 · 5 comments
Closed

Comments

@llaurila
Copy link

I upgraded my NextJS project to NextJS 4 & React 16 and react-intercom stopped working. Gives

TypeError: window.Intercom is not a function

on browser-side.

Any ideas?

@bsonntag
Copy link

bsonntag commented Feb 5, 2018

The Intercom initialization code should be moved from the constructor to the componentDidMount method.

@nhagen
Copy link
Owner

nhagen commented Feb 5, 2018

@bsonntag good point, looking at the code now I'm not sure if there was some reason for it being in the constructor other than because constructor is called once which is convenient. Since putting the tag on the page is a side effect, I would expect it to be in componentDidMount, and I would consider moving it to componentDidMount,. But this point seems kind of theoretical. its not clear to me how @llaurila's issue would be resolved by this. Can you elaborate? The cosntructor should be called before componentDidMountin any case.

@bsonntag
Copy link

bsonntag commented Feb 5, 2018

@nhagen I'm sorry, I thought this error was on the server.

@jefflewis
Copy link

I was running into this... I had created an activator for intercom with an id of "Intercom". This conflicted with window.Intercom. Changing my selector to <a id="intercom_help>Help Me</a> resolved my issues.

@WatsonFungHK
Copy link

You can avoid this kind of error by checking the existence of window before doing something on it
if (!!window.Intercom) { window.Intercom( /* what you want to do */); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants