react-native - Mixpanel.sharedInstanceWithToken 不是本机反应中的功能
问题描述
我想将 Mixpanel 与 React Native 集成,我使用了这个 github 源 https://github.com/davodesign84/react-native-mixpanel
我尝试了与描述相同的方法,但收到了此消息
Mixpanel.sharedInstanceWithToken is not a function
和'Mixpanel.sharedInstanceWithToken' is undefined)
var Mixpanel = require('react-native-mixpanel');
componentDidMount() {
console.log('============>', Mixpanel) // it returns object
Mixpanel.sharedInstanceWithToken('xxx');
}
我试了很多次都没有成功。应用程序启动成功,但在我使用 Mixpanel.sharedInstanceWithToken('xxx') 的屏幕中停止
谢谢你。
解决方案
正如@savelichalex 在评论中提到的那样,使用它会起作用:
const Mixpanel = require('react-native-mixpanel');
Mixpanel.default.sharedInstanceWithToken('MY_TOKEN');
推荐阅读
- java - 使用 -Xmx32m java 命令的 3 个文件中的最大单词出现次数
- python - Python TypeError:“函数”对象不能解释为整数
- javascript - 如何形成比较单个集合中的两个字段的firestore查询?
- sql - 学习Oracle,根据日期设置布尔值
- c - " Visual Studio Code 的用户片段中的符号使用
- c# - Newtonsoft.Json MVC:如何为失败的 json 验证自定义 DTO 错误消息
- java - 你能告诉我如何正确编辑这个 java 注释 mongodb @Query("{ 'ask': ?0}") 吗?
- sql - 对同一数据库的相同查询在不同时区返回不同结果
- python - 谷歌云平台 SQL 实例连接到 python 应用程序
- swift - 以编程方式触发 UITextField 的editingChanged