import React from 'react/addons'; import ChatStore from '../stores/ChatStore'; import ChatActions from '../actions/ChatActions'; const Chat = React.createClass({ propTypes: { io: React.PropTypes.object.isRequired, token: React.PropTypes.string.isRequired, color: React.PropTypes.oneOf(['white', 'black']).isRequired, soundsEnabled: React.PropTypes.bool.isRequired, isOpponentAvailable: React.PropTypes.bool.isRequired, openModal: React.PropTypes.func.isRequired }, mixins: [React.addons.PureRenderMixin], getInitialState() { const state = ChatStore.getState(); return { isChatHidden: state.isChatHidden, messages: state.messages, message: '', }; }, componentDidMount() { this.props.io.on('receive-message', data => { ChatActions.submitMessage(data.message, data.color + ' left', true); this._maybePlaySound(); }); ChatStore.on('change', this._onChatStoreChange); if (window.innerWidth > 1399) ChatActions.toggleVisibility(); }, componentWillUnmount() { ChatStore.off('change', this._onChatStoreChange); }, render() { return (