Last active
March 14, 2017 15:46
-
-
Save mrcnkoba/1bd8b72bc57756a82cd8489b80d871f9 to your computer and use it in GitHub Desktop.
This file contains 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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
export default class Example extends React.Component { | |
_appendScript(source) { | |
const script = document.createElement("script"); | |
script.setAttribute("type", "text/javascript"); | |
script.setAttribute("src", source); | |
document.body.appendChild(script); | |
} | |
componentDidMount() { | |
this._appendScript("https://cdn.talkjs.com/talk.js"); | |
this._appendScript("https://cdn.talkjs.com/talk-ui.js"); | |
window.onTalkLoaded = function() { | |
var me = new Talk.User({ | |
id: "12345", | |
name: "George Looney", | |
email: "george@looney.net", | |
photoUrl: "https://talkjs.com/docs/img/george.jpg", | |
welcomeMessage: "Hey there! How are you? :-)" | |
}); | |
window.talkSession = new Talk.Session({ | |
appId: "Hku1c4Pt", | |
publishableKey: "984769823478928374", | |
me: me | |
}); | |
}; | |
window.onTalkUiLoaded = function() { | |
var other = new Talk.User({ | |
id: "54321", | |
name: "Ronald Raygun", | |
email: "ronald@teflon.com", | |
photoUrl: "https://talkjs.com/docs/img/ronald.jpg", | |
welcomeMessage: "Hey there! Love to chat :-)" | |
}); | |
var conversation = window.talkSession.getOrStartConversation(other); | |
var inbox = window.talkSession.createInbox({selected: conversation}); | |
inbox.mount(document.getElementById("talkjs-container")); | |
}; | |
} | |
render() { | |
return <span> | |
<div id="talkjs-container">Loading...</div> | |
</span>; | |
} | |
} | |
window.view = ReactDOM.render(<Example/>, document.getElementById("hello")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment