Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mixpanel.sharedInstanceWithToken is not a function in react native

I would like to integrate Mixpanel with React Native, I used this github source https://github.com/davodesign84/react-native-mixpanel

I tried all the same as described but I got this messages

Mixpanel.sharedInstanceWithToken is not a function

And 'Mixpanel.sharedInstanceWithToken' is undefined)

    var Mixpanel = require('react-native-mixpanel');

     componentDidMount() {
        console.log('============>', Mixpanel) // it returns object 
        Mixpanel.sharedInstanceWithToken('xxx');
    }

enter image description here

I tried many times with no success. App launches successfully but stops in the screen I used Mixpanel.sharedInstanceWithToken('xxx')

Thank you.

like image 966
Nomura Nori Avatar asked Jul 02 '26 02:07

Nomura Nori


1 Answers

As @savelichalex mentioned in the comments using this will work:

const Mixpanel = require('react-native-mixpanel');
Mixpanel.default.sharedInstanceWithToken('MY_TOKEN');
like image 121
Kasra Avatar answered Jul 04 '26 12:07

Kasra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!