aboutsummaryrefslogtreecommitdiff
path: root/src/components/Header/SearchBar.tsx
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-12 02:32:57 +0300
committereug-vs <eug-vs@keemail.me>2020-08-12 02:32:57 +0300
commitafda959598a04553e0a27c5b543f161472b79828 (patch)
treec33eb6627ed76fa74efbe0757df5feafb612a521 /src/components/Header/SearchBar.tsx
parentb5ce9be31993f5b4bee9abbe57d775b7ea407507 (diff)
downloadwhich-ui-afda959598a04553e0a27c5b543f161472b79828.tar.gz
feat: implement mobile search
Diffstat (limited to 'src/components/Header/SearchBar.tsx')
-rw-r--r--src/components/Header/SearchBar.tsx7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/components/Header/SearchBar.tsx b/src/components/Header/SearchBar.tsx
index 8bfe0fb..ea6e6ac 100644
--- a/src/components/Header/SearchBar.tsx
+++ b/src/components/Header/SearchBar.tsx
@@ -15,6 +15,10 @@ import { User } from 'which-types';
import { get } from '../../requests';
import UserStrip from '../UserStrip/UserStrip';
+interface PropTypes {
+ callback?: () => void;
+}
+
const INTERVAL = 300;
const LIMIT = 7;
@@ -37,7 +41,7 @@ const useStyles = makeStyles(theme => ({
}
}));
-const SearchBar: React.FC = React.memo(() => {
+const SearchBar: React.FC<PropTypes> = React.memo(({ callback }) => {
const [results, setResults] = useState<User[]>([]);
const [query, setQuery] = useState<string>('');
const [debouncedQuery, setDebouncedQuery] = useState<string>(query);
@@ -72,6 +76,7 @@ const SearchBar: React.FC = React.memo(() => {
const { username } = results[index];
history.push(`/profile/${username}`);
handleClose();
+ if (callback) callback();
};
const SearchResults = (