[在使用pubnub-react时对象不是React Native中的构造函数

问题描述 投票:0回答:1

我正在尝试将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

react-native constructor pubnub
1个回答
0
投票

以Anshika Agrawal的名义发布此帖子,以便此帖子有答案。

我使用pubnub而不是pubnub-react解决了该问题。我提到this link解决了我的问题– Anshika Agrawa

© www.soinside.com 2019 - 2024. All rights reserved.