Skip to Main Content
ASP.NET Core 3 and React
book

ASP.NET Core 3 and React

by Carl Rippon
December 2019
Intermediate to advanced content levelIntermediate to advanced
598 pages
12h 21m
English
Packt Publishing
Content preview from ASP.NET Core 3 and React

Handling form submission

We already have a submit button in the Form component that submits the form. We aren't handling the form submission yet though. Let's handle form submission, which includes a call to a function passed in by the consumer:

  1. In Form.tsx, let's import the FormEvent type from React:
import { FC, useState, createContext, FormEvent } from 'react';
  1. Let's add an event listener for the submit event in the Form component JSX:
<form noValidate={true} onSubmit={handleSubmit}>  ...</form>

When the submit button is clicked on the form, the submit event will be triggered and a function called handleSubmit will be invoked.

  1. Let's start to implement the handleSubmit function just beneath the validate function:
const handleSubmit ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET Core 5 and React - Second Edition

ASP.NET Core 5 and React - Second Edition

Carl Rippon
ASP.NET Core 5 for Beginners

ASP.NET Core 5 for Beginners

Andreas Helland, Vincent Maverick Durano, Jeffrey Chilberto, Ed Price

Publisher Resources

ISBN: 9781789950229Supplemental Content