From 841ec978bae3297357c3157a3adf846648771770 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 14 Nov 2019 13:44:52 +0300 Subject: react-router-dom hooks --- vnext/src/ui/Post.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'vnext/src/ui/Post.js') 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)); -- cgit v1.2.3