Netlify form validate then submit

I have a Gatsby/React build with a form connected to Netlify in a functional component, all working fine and outputting the submissions to the Netlify CP.

I’ve now added validation using react-hook-form and so want to preventDefault on submission to run the validator function and then submit upon successful validation.

The validation works fine, however I’m stuck trying to send the data via a function after the validation. I’ve attempted but to no success.

Any ideas where I’m going wrong here and how to pass the data to netlify within a function

import React, { useEffect } from "react"
import useForm from 'react-hook-form'

import ReCAPTCHA from "react-google-recaptcha"
import { useSpring, animated } from 'react-spring'

import "../../styles/inline/themes.scss"
import styles from "./style.module.scss"

const FormBlock = ( props ) => {
	const [fade, setFade] = useSpring(() => ({opacity: 0}))
	useEffect(() => {	
		setFade({ opacity: 1, config: { duration: 900 }, delay: 100 })
	const { register, handleSubmit, errors } = useForm()
	const onSubmit = (data, e) => { 
	return (
		<section className={ styles.block }>
			<animated.div className={ `${ styles.overlay } background--${ props.bgColour }`} style={fade}>
				<div className={ styles.content }>
					{ props.title &&
								className: styles.title,
					{ props.text &&
						<p className={ props.columns } dangerouslySetInnerHTML={{ __html: props.text }}></p>
						<div className={ styles.field }>
								<p>Full name*</p>
								<input type="text" name="name" ref={register({ required: true })} />
							{ && <span>This field is required</span>}

						<div className={ styles.field }>
								<p>Email address*</p>
								<input type="email" name="email" ref={register({ required: true })} />
							{ && <span>This field is required</span>}

						<div className={ styles.field }>
								<p>Email address*</p>
								<textarea name="message" ref={register({ required: true })} />
							{errors.message && <span>This field is required</span>}

							className={ styles.recaptcha }
							sitekey="/*remove for question*/"/>
						<button className={ styles.button } type="submit">Send</button>

export default FormBlock

While I’m no javascript pro (or even amateur really), you do need to make sure your form is submitted as a POST, to the path (something like action=/thanks) specified in your plain html file that contains the identical html definition of the form.

Could you share a link to that plain html version of the form, and to the javascript form on a deploy preview, so we can give more direct advice?