nhagen / react-intercom

A component to configure and enable Intercom in your react application
MIT License
237 stars 72 forks source link

Trying to setup react-intercom #21

Closed dzeno closed 7 years ago

dzeno commented 7 years ago

I get this error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

I import react-intercom as import { Intercom } from 'react-intercom';.

UPDATE It works now, but I had to set it up 'manually' first. Meaning, I had to make sure my app is connected to Intercom, then I could use react-intercom. I followed this gist and I managed to connect app with Intercom. After that react-intercom seems to be working.

But it somehow doesn't make sense that I had to do this first, right?

jeremy-dorfschmidt commented 7 years ago

import Intercom from 'react-intercom' should solve this issue. I initially had { } around Intercom and had the same error.

nhagen commented 7 years ago

I was able to set this up just now in a new application without any special configuration--in the setup process, they automatically moved me to the next phase when I refreshed my page after inserting the component.

Any additional context you can share that could reproduce this? Unfortunately it is kind of annoying to create new Intercom instances just to test this.

Anyways, marking as resolved.

jeremy-dorfschmidt commented 7 years ago

@nhagen Just following up on this, so we shouldn't have to import Intercom from 'react-intercom'? A question around that is, then how does React know anything about the <Intercom .... /> component? I have react-intercom installed (package.json), however wiring the component just as per the instructions on the front page, no import in component, no script import. I have in my app <Intercom appID="my app id" {...user}/> when I do this I get the following issue warning/errors.Warning: i(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object. a.(anonymous function) invariant.js:44 Uncaught Error: i(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.

nhagen commented 7 years ago

Sorry, I'll add the import to the README to make it more clear. I am able to get past the verification step by simply importing the component as normal and use it in an application.

Can you provide an example of your code? That would help me understand if there's a specific way you're doing this that I haven't considered which doesn't work.

Edit: after updating the readme, I realize it wasn't apparent that the export you needed was the default export rather than a named export--if you're doing import { Intercom } from 'react-intercom', Intercom will be undefined, possibly causing that error you're getting. It should be import Intercom from 'react-intercom'