From 1a9fb01bcf64a4016fc8167f51871df1a85b692d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 8 Apr 2019 20:53:45 +0300 Subject: Cleanup ESLint warnings --- vnext/src/components/Thread.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'vnext/src/components/Thread.js') diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index 90a7be90..22972752 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -1,10 +1,8 @@ import React, { useEffect, useState, useRef } from 'react'; +import PropTypes from 'prop-types'; import ReactRouterPropTypes from 'react-router-prop-types'; -import { UserType } from './Types'; - -import { Link } from 'react-router-dom'; -import moment from 'moment'; +import { UserType, MessageType } from './Types'; import Message from './Message'; import MessageInput from './MessageInput'; @@ -73,6 +71,14 @@ function Comment({ msg, visitor, active, setActive, postComment }) { ); } +Comment.propTypes = { + msg: MessageType.isRequired, + visitor: UserType.isRequired, + active: PropTypes.bool.isRequired, + setActive: PropTypes.func.isRequired, + postComment: PropTypes.func.isRequired +}; + export default function Thread(props) { const [message, setMessage] = useState(props.location.state || {}); const [replies, setReplies] = useState([]); @@ -88,7 +94,7 @@ export default function Thread(props) { if (props.connection) { props.connection.removeEventListener('msg', onReply); } - } + }; }, [props.connection]); let loadReplies = () => { document.body.scrollTop = 0; @@ -113,20 +119,20 @@ export default function Thread(props) { ).catch(ex => { console.log(ex); }); - } + }; let onReply = (json) => { const msg = JSON.parse(json.data); if (msg.mid == message.mid) { setReplies([...this.state.replies, msg]); } - } + }; let postComment = (template) => { const { mid, rid, body, attach } = template; comment(mid, rid, body, attach).then(res => { loadReplies(); }) .catch(console.log); - } + }; const loaders = Math.min(message.replies || 0, 10); return ( @@ -165,5 +171,6 @@ Thread.propTypes = { location: ReactRouterPropTypes.location, history: ReactRouterPropTypes.history, match: ReactRouterPropTypes.match, - visitor: UserType.isRequired + visitor: UserType.isRequired, + connection: PropTypes.shape.isRequired }; -- cgit v1.2.3