From d2f8c0e50315c072a3173adbbcac55b659cfebe2 Mon Sep 17 00:00:00 2001 From: Charudatta Potdar Date: Tue, 20 Jun 2023 13:25:29 +0530 Subject: [PATCH] Implemented the code to clear the search bar after submitting the form --- src/components/Form.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/Form.js b/src/components/Form.js index 78ef1628..b1acf5a2 100644 --- a/src/components/Form.js +++ b/src/components/Form.js @@ -3,13 +3,16 @@ import React, { useState } from "react"; const Form = ({ handleSubmit, history }) => { const [searchEntry, setSearchEntry] = useState(""); // update search text state - const updateSearchInput = e => { + const updateSearchInput = (e) => { setSearchEntry(e.target.value); }; return (
handleSubmit(e, history, searchEntry)} + onSubmit={(e) => { + handleSubmit(e, history, searchEntry); + setSearchEntry(""); + }} >