Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
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 Respuestas
Responde la pregunta

0

Try canceling e.preventDefault ();

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda