Closed jorge-sanz closed 5 years ago
Mixpanel.default.sharedInstanceWithToken(TOKEN);
All must be Mixpanel.default
please Fix this issue or update your Document @davodesign84
@syafiq90 it's working right now for me. Not sure how I fixed it. I restarted the project again.
hey guys, we are getting the same issue:
Mixpanel.sharedInstanceWithToken("APIxxxxxx")
Error: `TypeError: Cannot read property 'sharedInstanceWithToken' of undefined.
Versions:
When console logging Mixpanel
the functions show up as expected:
Let me know if you need any more info!
Cheers
It looks like RNMixpanel
is undefined
in node_modules/react-native-mixpanel/index.js
line 4:
const { RNMixpanel } = NativeModules
I forgot to link it in xcode 🤦♂️:
Go to node_modules ➜ react-native-mixpanel and add RNMixpanel.xcodeproj In XCode, in the project navigator, select your project. Add libRNMixpanel.a to your project's Build Phases ➜ Link Binary With Libraries
import Mixpanel from 'react-native-mixpanel'
instead of var Mixpanel = require('react-native-mixpanel')
did it for me.
The module now exports a default
object and a MixpanelInstance
object. Therefore, the above default import should be used or import {MixpanelInstance} from 'react-native-mixpanel'
for the new (?) interface
you can use like this, i found in file index.js:
const mixpanel = new MixpanelInstance(TOKEN)
await mixpanel.initialize()
mixpanel.track('my event')
My issue was not in the Javascript, but in this:
https://github.com/davodesign84/react-native-mixpanel/issues/50#issuecomment-258065688
Try to import without braces like :
import Mixpanel from 'react-native-mixpanel';
I am getting this error with this code:
Any idea of how to solve it? Thank you so much! 🙂