Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
My Search isnt working, doesnt go to /products/

If I go to /products/ and add in the end anything, It will Search from all the products, but when I try to press the search button, it doesnt do anything, not even go to /products/.

I dont know if I should use Button instead of input, I'm following a tutorial and it works there

const Search = ({ history }) => {

const [keyword, setKeyword] = useState("");

const searchSubmitHandler = (e) => {
    e.preventDefault();
    if (keyword.trim()) {
        history.push(`/products/${keyword}`);
    } else{
        history.push("/products");
    }
};

return (
<Fragment>
<form className="searchBox" onSubmit={searchSubmitHandler}>
 <input
    type="text"
    placeholder="Search a Product ..."
    onChange={(e) => setKeyword(e.target.value)}
 />
 <input type="submit" value="Search" />
</form>
</Fragment>
);   
};
export default Search here
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try canceling e.preventDefault ();

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!