diff options
author | Vitaly Takmazov | 2019-11-14 13:44:52 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:55 +0300 |
commit | 841ec978bae3297357c3157a3adf846648771770 (patch) | |
tree | 7163d3a814fd68193f04415e5f1aeaf8a2cfd0a4 /vnext/src/ui/Post.js | |
parent | 3900358ca6eeac546cbe0eb0bd36572ddc404634 (diff) |
react-router-dom hooks
Diffstat (limited to 'vnext/src/ui/Post.js')
-rw-r--r-- | vnext/src/ui/Post.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/vnext/src/ui/Post.js b/vnext/src/ui/Post.js index 35704f11..407f3b62 100644 --- a/vnext/src/ui/Post.js +++ b/vnext/src/ui/Post.js @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { useLocation, useHistory } from 'react-router-dom'; import qs from 'qs'; @@ -8,9 +9,11 @@ import MessageInput from './MessageInput'; import { post, update } from '../api'; /** - * @param {{location: import('history').Location, visitor: import('../api').User, history: import('history').History}} props + * @param {{visitor: import('../api').User}} props */ -export default function Post({ location, visitor, history }) { +export default function Post({ visitor }) { + const location = useLocation(); + const history = useHistory(); let draftMessage = (location.state || {}).draft || {}; let [draft, setDraft] = useState(draftMessage.body); let params = qs.parse(window.location.search.substring(1)); |