Skip to content

Instantly share code, notes, and snippets.

@wclittle

wclittle/Chat.js Secret

Last active December 30, 2015 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wclittle/f33739af9ee4d347df48 to your computer and use it in GitHub Desktop.
Save wclittle/f33739af9ee4d347df48 to your computer and use it in GitHub Desktop.
import React, { Component, PropTypes } from 'react';
class Chat extends Component {
render() {
const { messages, addMessage } = this.props;
const handleSubmit = (e) => {
e.preventDefault();
};
const handleKeyUp = (e) => {
if(e.keyCode == 13){
App.room.speak(e.target.value);
e.target.value = "";
};
};
return (
<div>
<ul>
{messages.map((msg) => {
return <li key={`chat.msg.${msg.id}`}>{msg.content}</li>;
})
}
</ul>
<form onSubmit={handleSubmit}>
<input type="text" onKeyUp={handleKeyUp}/>
</form>
</div>
);
}
}
Chat.propTypes = {
messages: PropTypes.any
};
export default Chat;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment