December 2019
Intermediate to advanced
598 pages
12h 21m
English
In Header.tsx, carry out the following steps to implement submission on the search form:
import { ChangeEvent, FC, useState, FormEvent } from 'react';
const handleSearchSubmit = (e: FormEvent<HTMLFormElement>) => { e.preventDefault(); history.push(`/search?criteria=${search}`);};
So, this sets the browser location path to search with the appropriate criteria query parameter.
<form onSubmit={handleSearchSubmit}> <input ... /></form>
Our project isn't compiling yet because we need to pass the onSubmit function prop into the Form
Read now
Unlock full access