diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-08-08 11:28:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-08 11:28:07 +0300 |
commit | 70d533d2bcbaa689d3de6ecb532997cd68a7a842 (patch) | |
tree | 0199ab8a91f3e1bd5df0865c10695dde20a5303f /src/components/Header/SearchBar.tsx | |
parent | 84eaed2f29ac370eea7c4a7ded6fb3d4661c9679 (diff) | |
parent | 104c658fc411536e09931191721411de448f964f (diff) | |
download | which-ui-70d533d2bcbaa689d3de6ecb532997cd68a7a842.tar.gz |
Merge pull request #72 from which-ecosystem/feat/routing
Add basic routing
Diffstat (limited to 'src/components/Header/SearchBar.tsx')
-rw-r--r-- | src/components/Header/SearchBar.tsx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/components/Header/SearchBar.tsx b/src/components/Header/SearchBar.tsx index ba0943b..f541589 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,10 +11,9 @@ 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'; - const INTERVAL = 300; const LIMIT = 7; @@ -41,7 +41,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 +69,8 @@ const SearchBar: React.FC = () => { }; const handleNavigate = (index: number) => () => { - navigate('profile', results[index]._id); + const { username } = results[index]; + history.push(`/profile/${username}`); handleClose(); }; |