Last active
June 4, 2018 16:11
-
-
Save bookercodes/46cfda6755e27cd32fe316b3ec9155a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./src/Chat.js | |
import React, { Component } from 'react' | |
import { ChatManager, TokenProvider } from '@pusher/chatkit' | |
class Chat extends Component { | |
state = { | |
currentUser: null | |
} | |
componentDidMount() { | |
const chatkit = new ChatManager({ | |
instanceLocator: 'v1:us1:072d42ca-bcc6-4b19-bfe3-926a1e7d04db', | |
userId: this.props.currentId, | |
tokenProvider: new TokenProvider({ | |
url: | |
'https://us1.pusherplatform.io/services/chatkit_token_provider/v1/072d42ca-bcc6-4b19-bfe3-926a1e7d04db/token' | |
}) | |
}) | |
chatkit | |
.connect() | |
.then(currentUser => { | |
this.setState({ currentUser }) | |
console.log('Bleep bloop 🤖 You are connected to Chatkit') | |
}) | |
.catch(error => console.error('error', error)) | |
} | |
render() { | |
return ( | |
<div> | |
<h1>Chat Screen</h1> | |
</div> | |
) | |
} | |
} | |
export default Chat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment