diff options
author | 2018-07-06 01:32:43 +0300 | |
---|---|---|
committer | 2023-01-13 10:37:53 +0300 | |
commit | 7f25b0f261b5a5fc2696054004fb24673375b91b (patch) | |
tree | 38ee591e176b4799e39eff7a16f1950e017e7bb4 /vnext/src/components/Post.js | |
parent | 88732ba8c06c23a93f7248b6eabc182f38be3d33 (diff) |
Proptypes & eslint
Diffstat (limited to 'vnext/src/components/Post.js')
-rw-r--r-- | vnext/src/components/Post.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/vnext/src/components/Post.js b/vnext/src/components/Post.js index e8ebab5c..ff99cc27 100644 --- a/vnext/src/components/Post.js +++ b/vnext/src/components/Post.js @@ -1,4 +1,8 @@ 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'; @@ -7,23 +11,23 @@ import { post } from '../api'; export default class Post extends React.Component { constructor(props) { - super(props) + super(props); let params = qs.parse(window.location.search); this.state = { attach: '', body: params.body || '' } this.fileinput = React.createRef(); - console.log(props) + console.log(props); } postMessage = (template) => { const { attach, body } = template; post(body, attach) .then(response => { - console.log(response) + console.log(response); if (response.status === 200) { const msg = response.data.newMessage; - console.log(msg) + console.log(msg); this.props.history.push(`/${this.props.visitor.uname}/${msg.mid}`); } }).catch(console.log); @@ -31,22 +35,27 @@ export default class Post extends React.Component { attachChanged = (event) => { this.setState({ attach: event.target.value - }) + }); } bodyChanged = (event) => { this.setState({ body: event.target.value - }) + }); } render() { return ( <div className="msgs"> <article className="msg-cont"> - <MessageInput rows="7" text={this.state.body} data={{ mid: 0, timestamp: "0" }} onSend={this.postMessage}> - *weather It's very cold today! + <MessageInput rows="7" text={this.state.body} data={{ mid: 0, timestamp: '0' }} onSend={this.postMessage}> + *weather It is very cold today! </MessageInput> </article> </div> ); } } + +Post.propTypes = { + history: ReactRouterPropTypes.history.isRequired, + visitor: UserType +}; |