aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/Thread.js
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-11-14 13:44:52 +0300
committerGravatar Vitaly Takmazov2023-01-13 10:37:55 +0300
commit841ec978bae3297357c3157a3adf846648771770 (patch)
tree7163d3a814fd68193f04415e5f1aeaf8a2cfd0a4 /vnext/src/ui/Thread.js
parent3900358ca6eeac546cbe0eb0bd36572ddc404634 (diff)
react-router-dom hooks
Diffstat (limited to 'vnext/src/ui/Thread.js')
-rw-r--r--vnext/src/ui/Thread.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js
index 63bb2dd6..4f53c4af 100644
--- a/vnext/src/ui/Thread.js
+++ b/vnext/src/ui/Thread.js
@@ -1,4 +1,5 @@
import React, { useEffect, useState, useRef, useCallback } from 'react';
+import { useLocation, useParams } from 'react-router-dom';
import Message from './Message';
import MessageInput from './MessageInput';
@@ -11,7 +12,7 @@ import { format, embedUrls } from '../utils/embed';
import { getMessages, comment, update, markReadTracker, fetchUserUri, updateAvatar } from '../api';
-import { bubbleStyle, chatItemStyle } from './helpers/BubbleStyle';
+import { chatItemStyle } from './helpers/BubbleStyle';
import './Thread.css';
@@ -118,21 +119,21 @@ function Comment({ msg, draft, visitor, active, setActive, onStartEditing, postC
/**
* @param {{
- match: import('react-router').match,
- location: import('history').Location,
visitor: import('../api').SecureUser
connection: EventSource
}} props
*/
export default function Thread(props) {
- const [message, setMessage] = useState((props.location.state || {}).msg || {});
+ const location = useLocation();
+ const params = useParams();
+ const [message, setMessage] = useState((location.state || {}).msg || {});
const [replies, setReplies] = useState([]);
const [loading, setLoading] = useState(false);
const [active, setActive] = useState(0);
const [editing, setEditing] = useState(emptyMessage);
const [hash, setHash] = useState(props.visitor.hash);
- const { mid } = props.match.params;
+ const { mid } = params;
let loadReplies = useCallback(() => {
document.body.scrollTop = 0;
@@ -217,7 +218,10 @@ export default function Thread(props) {
</li>
)) : (
<>
- {Array(loaders).fill().map((it, i) => <Spinner key={i} />)}
+ {
+ // @ts-ignore
+ Array(loaders).fill().map((it, i) => <Spinner key={i} />)
+ }
</>
)
}