我正在尝试将pubnub-react集成到react native中。这是我的代码:
import React, { Component } from 'react';
import PubNubReact from 'pubnub-react';
import {key1,key2} from '../config.js
export default class extends Component {
constructor(props) {
super(props);
this.pubnub = new PubNubReact({
publishKey: key1,
subscribeKey: key2
});
this.pubnub.init(this)
}
render() {
return null
}
}
这将引发此错误:
[[TypeError: Object is not a constructor (evaluating 'new _pubnubReact.default')]][1]
react native版本为0.62.1
以Anshika Agrawal的名义发布此帖子,以便此帖子有答案。
我使用pubnub而不是pubnub-react解决了该问题。我提到this link解决了我的问题– Anshika Agrawa