import React from 'react'; 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(); console.log(props) } postMessage = (template) => { const { attach, body } = template; post(body, attach) .then(response => { console.log(response) if (response.status === 200) { const msg = response.data.newMessage; console.log(msg) 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 (
*weather It's very cold today!
); } }