Object is not a constructor in React Native when using pubnub-react

爱⌒轻易说出口 提交于 2020-05-16 05:45:52

问题


I am trying to integrate pubnub-react in react native. Here's my code:

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
  }
}

This is throwing this error:

[[TypeError: Object is not a constructor (evaluating 'new _pubnubReact.default')]][1]

Version of react native is 0.62.1


回答1:


A PubNub engineer should be posting answer soon.


Alternative solution Posting this on Anshika Agrawal's behalf so that this post has an answer.

I solved the issue using pubnub instead of using pubnub-react. I referred to this link which resolved my issue – Anshika Agrawa




回答2:


I solved the issue using pubnub instead of using pubnub-react. I refered to this link https://www.pubnub.com/docs/nodejs-javascript/pubnub-javascript-sdk which resolved my issue



来源:https://stackoverflow.com/questions/61080350/object-is-not-a-constructor-in-react-native-when-using-pubnub-react

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!