I am following tutorial about TicTacToe in react with PubNub and when I tried to start it it says pubnub-react does not contain a default export. Any ideas why is that?
Thanks in advance!
I am following tutorial about TicTacToe in react with PubNub and when I tried to start it it says pubnub-react does not contain a default export. Any ideas why is that?
Thanks in advance!
Yes, that's right, pubnub-react
haven't default export.
You can use it in 2 way
First
Using Destructuring Assignment
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
import { PubNubProvider, usePubNub } from 'pubnub-react';
import React from 'react';
import PubNub from 'pubnub';
import { PubNubProvider } from 'pubnub-react';
const pubnub = new PubNub({
publishKey: 'myPublishKey',
subscribeKey: 'mySubscribeKey',
uuid: 'myUniqueUUID'
});
function App() {
return (
<PubNubProvider client={pubnub}>
<Chat />
</PubNubProvider>
);
}
Second
export all module into one
using import * as <NAME>
import * as PubNubReact from 'pubnub-react';
import React from 'react';
import PubNub from 'pubnub';
import * as PubNubReact from 'pubnub-react';
const pubnub = new PubNub({
publishKey: 'myPublishKey',
subscribeKey: 'mySubscribeKey',
uuid: 'myUniqueUUID'
});
function App() {
return (
<PubNubReact.PubNubProvider client={pubnub}>
<Chat />
</PubNubReact.PubNubProvider>
);
}