aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-08 09:11:28 +0300
committereug-vs <eug-vs@keemail.me>2020-08-08 09:11:28 +0300
commitcc1133ff817218f80476d91ec509c5eaa6be86e6 (patch)
tree1f20098f55eaae50e16e8dd74c63b799bf691373 /src/components
parent0fe1f4138f870c4d00a02741bacf25165c94541e (diff)
downloadwhich-ui-cc1133ff817218f80476d91ec509c5eaa6be86e6.tar.gz
feat: support routing in SearchBar
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Header/SearchBar.tsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/components/Header/SearchBar.tsx b/src/components/Header/SearchBar.tsx
index ba0943b..f54cf25 100644
--- a/src/components/Header/SearchBar.tsx
+++ b/src/components/Header/SearchBar.tsx
@@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react';
+import { useHistory } from 'react-router-dom';
import SearchIcon from '@material-ui/icons/Search';
import {
InputBase,
@@ -10,9 +11,10 @@ import {
} from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { User } from 'which-types';
+
import { get } from '../../requests';
import UserStrip from '../UserStrip/UserStrip';
-import { useNavigate } from '../../hooks/useNavigate';
+import urls from '../../pages/urls';
const INTERVAL = 300;
@@ -41,7 +43,7 @@ const SearchBar: React.FC = () => {
const [results, setResults] = useState<User[]>([]);
const [query, setQuery] = useState<string>('');
const [debouncedQuery, setDebouncedQuery] = useState<string>(query);
- const { navigate } = useNavigate();
+ const history = useHistory();
const classes = useStyles();
useEffect(() => {
@@ -69,7 +71,8 @@ const SearchBar: React.FC = () => {
};
const handleNavigate = (index: number) => () => {
- navigate('profile', results[index]._id);
+ const { username } = results[index];
+ history.push(urls.profile(username));
handleClose();
};