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/App.js | 80 ++++++++++++++++++--------------- vnext/src/ui/Chat.js | 15 ++++--- vnext/src/ui/Feeds.js | 111 ++++++++++++++++++++++++---------------------- vnext/src/ui/Header.js | 20 ++++++--- vnext/src/ui/Login.js | 12 ++--- vnext/src/ui/Post.js | 7 ++- vnext/src/ui/SearchBox.js | 10 ++--- vnext/src/ui/Thread.js | 16 ++++--- vnext/src/ui/UserInfo.js | 28 +++++------- vnext/src/ui/Users.js | 25 ++++++----- 10 files changed, 175 insertions(+), 149 deletions(-) (limited to 'vnext') diff --git a/vnext/src/App.js b/vnext/src/App.js index 4c1e72d1..4251d52c 100644 --- a/vnext/src/App.js +++ b/vnext/src/App.js @@ -30,15 +30,14 @@ export default function App() { useEffect(() => { svg4everybody(); + let params = qs.parse(window.location.search.substring(1)); + if (params.hash) { + cookie.save('hash', params.hash, { path: '/' }); + let retpath = params.retpath || `${window.location.protocol}//${window.location.host}${window.location.pathname}`; + window.history.replaceState({}, document.title, retpath); + } }, []); - let params = qs.parse(window.location.search.substring(1)); - if (params.hash) { - cookie.save('hash', params.hash, { path: '/' }); - let retpath = params.retpath || `${window.location.protocol}//${window.location.host}${window.location.pathname}`; - window.history.replaceState({}, document.title, retpath); - } - /** * @type {import('./api').SecureUser} */ @@ -134,17 +133,6 @@ export default function App() { }); }, [hash]); - /** - * @param {{ pathname: any; search: string; }[]} history - * @param {any} pathname - * @param {any} searchString - */ - let search = (history, pathname, searchString) => { - let location = {}; - location.pathname = pathname; - location.search = `?search=${searchString}`; - history.push(location); - }; /** * @param {import("./api").SecureUser} visitor */ @@ -163,23 +151,45 @@ export default function App() {
- Next → + Next →
) }