From a3bc1dfd89081de9bdc619902dd7d5f9e77632a5 Mon Sep 17 00:00:00 2001 From: Kaamil Ahamadh Date: Fri, 18 Nov 2022 23:16:40 +0530 Subject: [PATCH] Fix Back Press after Searching --- src/screens/SearchResultsScreen.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/screens/SearchResultsScreen.js b/src/screens/SearchResultsScreen.js index 36d01ff..19dac47 100644 --- a/src/screens/SearchResultsScreen.js +++ b/src/screens/SearchResultsScreen.js @@ -1,10 +1,19 @@ -import React, { useContext } from "react"; +import React, { useContext, useEffect, useState } from "react"; import GlobalContext from "../context/GlobalContext"; import { VideoCardResults } from "../components"; +import { useNavigate } from "react-router-dom"; const SearchResultsScreen = () => { const { searchResults } = useContext(GlobalContext); + + const navigate = useNavigate(); + + useEffect(() => { + window.onpopstate = () => { + navigate("/"); + }; + }, []); return (
Search Results