TypeError:chatManager.connect(...)未定义

时间:2019-06-16 15:14:04

标签: node.js reactjs

我正在尝试在我的react js项目中使用chatkit api,但出现以下错误:

TypeError:chatManager.connect(...)未定义 componentDidMount C:/用户/管理员/聊天应用/src/App.js:33   30 |   31 |
  32 |

  

33 | chatManager.connect()。then(currentUser => {        | ^ 34 | currentUser.subscribeToRoom({     35 | roomId:19436903,     36 |钩子:{

import React from 'react';
import Chatkit from 'pusher-chatkit-client';
import connect from 'pusher-chatkit-server';

//import Chatkit from 'pusher/chatkit';

import './App.css';
import RoomList from './RoomList';
import MessageList from './MessageList';
import SendMessageForm from './SendMessageForm';
import NewRoomForm from './CreateRoomForm';
//import {tokenUrl , instanceLocator} from './config.js';



class App extends React.Component
{

  componentDidMount()
  {
    const chatManager=new Chatkit.ChatManager
    ({
      instanceLocator:'v1:us1:a34c45b2-2af9-4f63-a532-fe189495f655',
      userId:'manju',
      tokenProvider:new Chatkit.TokenProvider
      ({
        url:'https://us1.pusherplatform.io/services/chatkit_token_provider/v1/a34c45b2-2af9-4f63-a532-fe189495f655/token'
      })
    });



  chatManager.connect().then(currentUser=> {
     currentUser.subscribeToRoom({
        roomId:19436903,
        hooks:{
          onNewMessage:message=>{
            console.log('message.text :',message.text);
          }
        }
      })
      })

  }

TypeError:chatManager.connect(...)未定义 componentDidMount C:/用户/管理员/聊天应用/src/App.js:33   30 |   31 |
  32 |

  

33 | chatManager.connect()。then(currentUser => {        | ^ 34 | currentUser.subscribeToRoom({     35 | roomId:19436903,     36 |钩子:{

0 个答案:

没有答案