-
{
chats.map((chat) =>
No chat selected
import React from 'react'; import moment from 'moment'; import PM from './PM'; import MessageInput from './MessageInput'; import { getChat, pm } from '../api'; export default class Chat extends React.Component { constructor(props) { super(props); this.state = { chats: [] }; } componentWillMount() { this.loadChat(this.props.match.params.user); } loadChat = (uname) => { const { hash } = this.props.visitor; this.setState({ chats: [] }); if (hash && uname) { getChat(uname) .then(response => { this.setState({ chats: response.data }); }); } } onSend = (template) => { pm(template.to.uname, template.body) .then(res => { this.loadChat(this.props.match.params.user); }).catch(console.log) } render() { const { chats } = this.state; const uname = this.props.match.params.user; return (
No chat selected