diff --git a/src/components/SearchBox/SearchBox.component.jsx b/src/components/SearchBox/SearchBox.component.jsx
index 90fe7d528..a5cf11961 100644
--- a/src/components/SearchBox/SearchBox.component.jsx
+++ b/src/components/SearchBox/SearchBox.component.jsx
@@ -1,7 +1,6 @@
import React, { useState } from 'react';
import styled from 'styled-components';
import { createHashHistory } from 'history';
-import { types } from '../../utils/constants';
import { useSearch } from '../../providers/Search/Search.provider';
const TextBox = styled.input`
@@ -35,15 +34,15 @@ const TextBox = styled.input`
`;
function SearchBox() {
- const [state, dispatch] = useSearch();
- const [value, setValue] = useState("");
+ const { searchTerm, setSearchTerm } = useSearch();
+ const [value, setValue] = useState('');
const history = createHashHistory();
const ENTER_KEY = 13;
function searchIt(e) {
- let search = e.target.value.trim()
- if (state.query !== search) {
- dispatch({ type: types.QUERY, term: search });
+ let search = e.target.value.trim();
+ if (searchTerm !== search) {
+ setSearchTerm(search);
}
const currentPath = window.location.hash;
diff --git a/src/pages/Home/Home.page.jsx b/src/pages/Home/Home.page.jsx
index 66671191e..ffbf86b0f 100644
--- a/src/pages/Home/Home.page.jsx
+++ b/src/pages/Home/Home.page.jsx
@@ -25,16 +25,16 @@ const Welcome = styled.h1`
`;
function HomePage() {
- const [state] = useSearch();
- const query = state.query;
+ const { searchTerm } = useSearch();
+ const query = searchTerm;
let params = {
q: query,
type: 'video',
part: ['id', 'snippet'],
order: 'relevance',
- maxResults: 12
- }
+ maxResults: 12,
+ };
const [videos, isLoading, error] = useYTApi({ endpoint: 'search', params: params });
@@ -44,7 +44,7 @@ function HomePage() {