import React from 'react'; import ReactRouterPropTypes from 'react-router-prop-types'; import { UserType } from './Types'; import * as qs from 'query-string'; import MessageInput from './MessageInput'; import { post } from '../api'; export default class Post extends React.Component { constructor(props) { super(props); let params = qs.parse(window.location.search); this.state = { attach: '', body: params.body || '' }; this.fileinput = React.createRef(); } postMessage = (template) => { const { attach, body } = template; post(body, attach) .then(response => { if (response.status === 200) { const msg = response.data.newMessage; this.props.history.push(`/${this.props.visitor.uname}/${msg.mid}`); } }).catch(console.log); } attachChanged = (event) => { this.setState({ attach: event.target.value }); } bodyChanged = (event) => { this.setState({ body: event.target.value }); } render() { return (