<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ReactJS - Software Developer's Tour</title>
	<atom:link href="https://pawelmajewski.com/category/programming/javascript-typescript/react-js/feed/" rel="self" type="application/rss+xml" />
	<link>https://pawelmajewski.com</link>
	<description>Website about programming, news in IT and more</description>
	<lastBuildDate>Wed, 11 Jun 2025 08:58:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://pawelmajewski.com/wp-content/uploads/2024/02/logo_normal.png</url>
	<title>ReactJS - Software Developer's Tour</title>
	<link>https://pawelmajewski.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Simplify Your React Forms with React Hook Form and Yup</title>
		<link>https://pawelmajewski.com/simplify-your-react-forms-with-react-hook-form-and-yup/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simplify-your-react-forms-with-react-hook-form-and-yup</link>
					<comments>https://pawelmajewski.com/simplify-your-react-forms-with-react-hook-form-and-yup/#respond</comments>
		
		<dc:creator><![CDATA[Paweł Majewski]]></dc:creator>
		<pubDate>Mon, 12 May 2025 09:52:00 +0000</pubDate>
				<category><![CDATA[ReactJS]]></category>
		<category><![CDATA[Custom forms]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[React hook form]]></category>
		<category><![CDATA[ReactJs]]></category>
		<category><![CDATA[Validation]]></category>
		<category><![CDATA[Yup]]></category>
		<guid isPermaLink="false">https://pawelmajewski.com/?p=8788</guid>

					<description><![CDATA[<p>Here we are! The first post about frontend technology has been written. Until now, only backend and DevOps topics have been covered. Today I want to show you one of the top libraries that allows us to manage forms easily. React Hook Form and Yup What is React Hook Form? It&#8217;s one of the most frequently used library to manage forms with React. As we can read on the project&#8217;s site  Performance is one of the primary reasons why this library was created. https://react-hook-form.com/faqs What is Yup? Yup is a library used for creating schemas that help in parsing and validating values at runtime. npm install react-hook-form npm install @hookform/resolvers yup I have created simple form using bootstrap. In a standard case, we would create a useState or useRef for each field. It would result in a massive amount of code. However, it&#8217;s a good approach when you are new to React and still learning. By implementing it yourself, you will learn how React works and how to solve basic problems that surprise beginners. Okay, let&#8217;s get back to the main thread. I have created React with typescript, so let&#8217;s create a type that defines our form. type FormData = { firstName: string; lastName: string; age: number; email: string; password: string; } Then is good time to define our validation schema for this model. const schema: ObjectSchema&#60;FormData&#62; = yup .object({ firstName: yup.string().required(&#34;FirstName cannot be empty&#34;), lastName: yup.string().required(&#34;LastName cannot be empty&#34;), age: yup.number().positive(&#34;Age must be positive number&#34;).integer().required(&#34;Age cannot be empty&#34;).typeError(&#34;Age must be a number&#34;), email: yup.string().required(&#34;Email cannot be empty&#34;).matches(RegexConsts.email, &#34;Email must contain @ and . characters&#34;), password: yup.string().required(&#34;Password cannot be empty&#34;), }); Yup provides many validation methods. I won&#8217;t waste your time, so here I will only touch on the matches method. Matches method allows us to define regex pattern to validate this field. The second parameters means failed validation message. export const RegexConsts = { email: /.*[@].*[.][a-zA-Z]{2,}/ } React Hook Form validates forms based on configuration, in this case after submitting the form. Custom validation for age yup.number().positive(&#34;Age must be positive number&#34;).integer().required(&#34;Age cannot be empty&#34;).typeError(&#34;Age must be a number&#34;) When validation is successfully completed, the submit method returns our form object with the filled fields. The full file looks as presented below import { useForm } from &#34;react-hook-form&#34; import { yupResolver } from &#34;@hookform/resolvers/yup&#34; import * as yup from &#34;yup&#34; import { RegexConsts } from &#34;../consts/regexConsts&#34; import { ObjectSchema } from &#34;yup&#34; type FormData = { firstName: string; lastName: string; age: number; email: string; password: string; } const schema: ObjectSchema&#60;FormData&#62; = yup .object({ firstName: yup.string().required(&#34;FirstName cannot be empty&#34;), lastName: yup.string().required(&#34;LastName cannot be empty&#34;), age: yup.number().positive(&#34;Age must be positive number&#34;).integer().required(&#34;Age cannot be empty&#34;).typeError(&#34;Age must be a number&#34;), email: yup.string().required(&#34;Email cannot be empty&#34;).matches(RegexConsts.email, &#34;Email must contain @ and . characters&#34;), password: yup.string().required(&#34;Password cannot be empty&#34;), }); export default function RegisterForm() { const { register, handleSubmit, formState: { errors }, } = useForm&#60;FormData&#62;({ resolver: yupResolver(schema), }) const onSubmit = (data: FormData) =&#62; console.log(data) return ( &#60;&#62; &#60;form className=&#34;card p-2&#34; onSubmit={handleSubmit(onSubmit)}&#62; &#60;div className=&#34;row&#34;&#62; &#60;div className=&#34;col-md-6 mb-6&#34;&#62; &#60;div className=&#34;input-group&#34;&#62; &#60;label className=&#34;w-100&#34;&#62;First name &#60;input type=&#34;text&#34; className=&#34;form-control&#34; {...register(&#34;firstName&#34;)} /&#62; &#60;/label&#62; &#60;div className=&#34;invalid-feedback d-block&#34;&#62; {errors.firstName?.message} &#60;/div&#62; &#60;/div&#62; &#60;div className=&#34;input-group&#34;&#62; &#60;label className=&#34;w-100&#34;&#62;Last name &#60;input type=&#34;text&#34; className=&#34;form-control&#34; {...register(&#34;lastName&#34;)} /&#62; &#60;/label&#62; &#60;div className=&#34;invalid-feedback d-block&#34;&#62; {errors.lastName?.message} &#60;/div&#62; &#60;/div&#62; &#60;div className=&#34;input-group&#34;&#62; &#60;label className=&#34;w-100&#34;&#62;Age &#60;input type=&#34;text&#34; className=&#34;form-control&#34; {...register(&#34;age&#34;)} /&#62; &#60;/label&#62; &#60;div className=&#34;invalid-feedback d-block&#34;&#62; {errors.age?.message} &#60;/div&#62; &#60;/div&#62; &#60;div className=&#34;input-group&#34;&#62; &#60;label className=&#34;w-100&#34;&#62;Email &#60;input type=&#34;text&#34; className=&#34;form-control&#34; {...register(&#34;email&#34;)} /&#62; &#60;/label&#62; &#60;div className=&#34;invalid-feedback d-block&#34;&#62; {errors.email?.message} &#60;/div&#62; &#60;/div&#62; &#60;div className=&#34;input-group&#34;&#62; &#60;label className=&#34;w-100&#34;&#62;Password &#60;input type=&#34;password&#34; className=&#34;form-control&#34; {...register(&#34;password&#34;)} /&#62; &#60;/label&#62; &#60;div className=&#34;invalid-feedback d-block&#34;&#62; {errors.password?.message} &#60;/div&#62; &#60;/div&#62; &#60;/div&#62; &#60;div className=&#34;col-md-6 mb-6&#34;&#62; &#60;button type=&#34;submit&#34; className=&#34;btn btn-outline-success w-100&#34;&#62;Send&#60;/button&#62; &#60;/div&#62; &#60;/div&#62; &#60;/form&#62; &#60;/&#62; ) } I highly recommend using React Hook Form combined with Yup validation in your daily work with React.</p>
<p>The post <a href="https://pawelmajewski.com/simplify-your-react-forms-with-react-hook-form-and-yup/">Simplify Your React Forms with React Hook Form and Yup</a> first appeared on <a href="https://pawelmajewski.com">Software Developer's Tour</a>.</p>]]></description>
										<content:encoded><![CDATA[<div data-elementor-type="wp-post" data-elementor-id="8788" class="elementor elementor-8788">
				<div class="elementor-element elementor-element-eb501a8 e-flex e-con-boxed wpr-particle-no wpr-jarallax-no wpr-parallax-no wpr-sticky-section-no wpr-column-slider-no wpr-equal-height-no e-con e-parent" data-id="eb501a8" data-element_type="container" data-e-type="container">
					<div class="e-con-inner">
				<div class="elementor-element elementor-element-24353a1 elementor-widget elementor-widget-text-editor" data-id="24353a1" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Here we are! The first post about frontend technology has been written. Until now, only backend and DevOps topics have been covered.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-6a9add3 elementor-widget elementor-widget-text-editor" data-id="6a9add3" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Today I want to show you one of the top libraries that allows us to manage forms easily.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-29205e5 elementor-widget elementor-widget-heading" data-id="29205e5" data-element_type="widget" data-e-type="widget" data-widget_type="heading.default">
				<div class="elementor-widget-container">
					<h2 class="elementor-heading-title elementor-size-default">React Hook Form and Yup</h2>				</div>
				</div>
				<div class="elementor-element elementor-element-a9b34d4 elementor-widget elementor-widget-text-editor" data-id="a9b34d4" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>What is <strong>React Hook Form?</strong></p><p>It&#8217;s one of the most frequently used library to manage forms with <strong>React</strong>. As we can read on the project&#8217;s site </p>								</div>
				</div>
				<div class="elementor-element elementor-element-32c6ed5 elementor-widget elementor-widget-eael-testimonial" data-id="32c6ed5" data-element_type="widget" data-e-type="widget" data-widget_type="eael-testimonial.default">
				<div class="elementor-widget-container">
					
	<div id="eael-testimonial-32c6ed5" class="eael-testimonial-item clearfix  default-style">
				
		
								<div class="eael-testimonial-content">
				<div class="eael-testimonial-text"><p>Performance is one of the primary reasons why this library was created.</p><p><a href="https://react-hook-form.com/faqs" target="_blank" rel="noopener">https://react-hook-form.com/faqs</a></p></div>			</div>
		
		
		
		
		
		
		<span class="eael-testimonial-quote"></span>
	</div>

					</div>
				</div>
				<div class="elementor-element elementor-element-1a3ea45 elementor-widget elementor-widget-text-editor" data-id="1a3ea45" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>What is <strong>Yup?</strong></p><p>Yup is a library used for creating schemas that help in parsing and validating values at runtime.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-b732a55 elementor-widget elementor-widget-code-block-for-elementor" data-id="b732a55" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-cil'>npm install react-hook-form
npm install @hookform/resolvers yup</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-dc49f8b elementor-widget elementor-widget-text-editor" data-id="dc49f8b" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>I have created simple form using <a href="https://getbootstrap.com/" target="_blank" rel="noopener">bootstrap</a>.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-e29a66b elementor-widget elementor-widget-image" data-id="e29a66b" data-element_type="widget" data-e-type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
															<img loading="lazy" decoding="async" loading="lazy" width="1024" height="442" src="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_22h12_07-1024x442.png" class="attachment-large size-large wp-image-8795" alt="simple form" srcset="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_22h12_07-1024x442.png 1024w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_22h12_07-300x129.png 300w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_22h12_07-768x331.png 768w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_22h12_07.png 1370w" sizes="auto, (max-width: 1024px) 100vw, 1024px" />															</div>
				</div>
				<div class="elementor-element elementor-element-9420c74 elementor-widget elementor-widget-text-editor" data-id="9420c74" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>In a standard case, we would create a <strong>useState </strong>or <strong>useRef</strong> for each field. It would result in a massive amount of code. However, it&#8217;s a good approach when you are new to <strong>React</strong> and still learning. By implementing it yourself, you will learn how <strong>React</strong> works and how to solve basic problems that surprise beginners. Okay, let&#8217;s get back to the main thread.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-79259ee elementor-widget elementor-widget-text-editor" data-id="79259ee" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>I have created <strong>React</strong> with typescript, so let&#8217;s create a type that defines our form.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-195a85a elementor-widget elementor-widget-code-block-for-elementor" data-id="195a85a" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-typescript'>type FormData = {
    firstName: string;
    lastName: string;
    age: number;
    email: string;
    password: string;
}</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-d4f8828 elementor-widget elementor-widget-text-editor" data-id="d4f8828" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Then is good time to define our validation schema for this model.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-57c22fc elementor-widget elementor-widget-code-block-for-elementor" data-id="57c22fc" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-typescript'>const schema: ObjectSchema&lt;FormData&gt; = yup
    .object({
        firstName: yup.string().required(&quot;FirstName cannot be empty&quot;),
        lastName: yup.string().required(&quot;LastName cannot be empty&quot;),
        age: yup.number().positive(&quot;Age must be positive number&quot;).integer().required(&quot;Age cannot be empty&quot;).typeError(&quot;Age must be a number&quot;),
        email: yup.string().required(&quot;Email cannot be empty&quot;).matches(RegexConsts.email, &quot;Email must contain @ and . characters&quot;),
        password: yup.string().required(&quot;Password cannot be empty&quot;),
    });</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-18bbc8a elementor-widget elementor-widget-text-editor" data-id="18bbc8a" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Yup provides many validation methods. I won&#8217;t waste your time, so here I will only touch on the <code>matches</code> method.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-6ed6ceb elementor-widget elementor-widget-text-editor" data-id="6ed6ceb" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p><code>Matches</code> method allows us to define regex pattern to validate this field. The second parameters means failed validation message.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-97bdf71 elementor-widget elementor-widget-code-block-for-elementor" data-id="97bdf71" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-javascript'>export const RegexConsts = {
    email: /.*[@].*[.][a-zA-Z]{2,}/
}</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-5874aaa elementor-widget elementor-widget-text-editor" data-id="5874aaa" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>React Hook Form validates forms based on configuration, in this case after submitting the form.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-82204ba elementor-widget elementor-widget-image" data-id="82204ba" data-element_type="widget" data-e-type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
															<img loading="lazy" decoding="async" loading="lazy" width="1024" height="505" src="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h00_49-1024x505.png" class="attachment-large size-large wp-image-8808" alt="validation failed" srcset="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h00_49-1024x505.png 1024w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h00_49-300x148.png 300w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h00_49-768x379.png 768w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h00_49.png 1339w" sizes="auto, (max-width: 1024px) 100vw, 1024px" />															</div>
				</div>
				<div class="elementor-element elementor-element-df05710 elementor-widget elementor-widget-text-editor" data-id="df05710" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>Custom validation for age</p>								</div>
				</div>
				<div class="elementor-element elementor-element-e972c28 elementor-widget elementor-widget-code-block-for-elementor" data-id="e972c28" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-typescript'>yup.number().positive(&quot;Age must be positive number&quot;).integer().required(&quot;Age cannot be empty&quot;).typeError(&quot;Age must be a number&quot;)</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-307ad31 elementor-widget elementor-widget-image" data-id="307ad31" data-element_type="widget" data-e-type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
															<img loading="lazy" decoding="async" loading="lazy" width="678" height="96" src="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h04_30.png" class="attachment-large size-large wp-image-8809" alt="type validation" srcset="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h04_30.png 678w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h04_30-300x42.png 300w" sizes="auto, (max-width: 678px) 100vw, 678px" />															</div>
				</div>
				<div class="elementor-element elementor-element-67898fe elementor-widget elementor-widget-image" data-id="67898fe" data-element_type="widget" data-e-type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
															<img loading="lazy" decoding="async" loading="lazy" width="658" height="93" src="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_09.png" class="attachment-large size-large wp-image-8810" alt="positive error validation" srcset="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_09.png 658w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_09-300x42.png 300w" sizes="auto, (max-width: 658px) 100vw, 658px" />															</div>
				</div>
				<div class="elementor-element elementor-element-bc9140d elementor-widget elementor-widget-text-editor" data-id="bc9140d" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>When validation is successfully completed, the submit method returns our form object with the filled fields.</p>								</div>
				</div>
				<div class="elementor-element elementor-element-f3c2de6 elementor-widget elementor-widget-image" data-id="f3c2de6" data-element_type="widget" data-e-type="widget" data-widget_type="image.default">
				<div class="elementor-widget-container">
															<img loading="lazy" decoding="async" loading="lazy" width="1024" height="512" src="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_30-1024x512.png" class="attachment-large size-large wp-image-8811" alt="validation success" srcset="https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_30-1024x512.png 1024w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_30-300x150.png 300w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_30-768x384.png 768w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_30-1536x767.png 1536w, https://pawelmajewski.com/wp-content/uploads/2024/06/2024-06-01_23h01_30-2048x1023.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" />															</div>
				</div>
				<div class="elementor-element elementor-element-cda05ce elementor-widget elementor-widget-text-editor" data-id="cda05ce" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>The full file looks as presented below</p>								</div>
				</div>
				<div class="elementor-element elementor-element-6724d21 elementor-widget elementor-widget-code-block-for-elementor" data-id="6724d21" data-element_type="widget" data-e-type="widget" data-widget_type="code-block-for-elementor.default">
				<div class="elementor-widget-container">
					<pre class='line-numbers theme-okaidia' data-show-toolbar='yes'><code class='language-typescript'>import { useForm } from &quot;react-hook-form&quot;
import { yupResolver } from &quot;@hookform/resolvers/yup&quot;
import * as yup from &quot;yup&quot;
import { RegexConsts } from &quot;../consts/regexConsts&quot;
import { ObjectSchema } from &quot;yup&quot;

type FormData = {
    firstName: string;
    lastName: string;
    age: number;
    email: string;
    password: string;
}

const schema: ObjectSchema&lt;FormData&gt; = yup
    .object({
        firstName: yup.string().required(&quot;FirstName cannot be empty&quot;),
        lastName: yup.string().required(&quot;LastName cannot be empty&quot;),
        age: yup.number().positive(&quot;Age must be positive number&quot;).integer().required(&quot;Age cannot be empty&quot;).typeError(&quot;Age must be a number&quot;),
        email: yup.string().required(&quot;Email cannot be empty&quot;).matches(RegexConsts.email, &quot;Email must contain @ and . characters&quot;),
        password: yup.string().required(&quot;Password cannot be empty&quot;),
    });


export default function RegisterForm() {
    const {
        register,
        handleSubmit,
        formState: { errors },
    } = useForm&lt;FormData&gt;({
        resolver: yupResolver(schema),
    })

    const onSubmit = (data: FormData) =&gt; console.log(data)

    return (
        &lt;&gt;
            &lt;form className=&quot;card p-2&quot; onSubmit={handleSubmit(onSubmit)}&gt;
                &lt;div className=&quot;row&quot;&gt;
                    &lt;div className=&quot;col-md-6 mb-6&quot;&gt;
                        &lt;div className=&quot;input-group&quot;&gt;
                            &lt;label className=&quot;w-100&quot;&gt;First name
                                &lt;input type=&quot;text&quot; className=&quot;form-control&quot; {...register(&quot;firstName&quot;)} /&gt;
                            &lt;/label&gt;
                            &lt;div className=&quot;invalid-feedback d-block&quot;&gt;
                                {errors.firstName?.message}
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div className=&quot;input-group&quot;&gt;
                            &lt;label className=&quot;w-100&quot;&gt;Last name
                                &lt;input type=&quot;text&quot; className=&quot;form-control&quot; {...register(&quot;lastName&quot;)} /&gt;
                            &lt;/label&gt;
                            &lt;div className=&quot;invalid-feedback d-block&quot;&gt;
                                {errors.lastName?.message}
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div className=&quot;input-group&quot;&gt;
                            &lt;label className=&quot;w-100&quot;&gt;Age
                                &lt;input type=&quot;text&quot; className=&quot;form-control&quot; {...register(&quot;age&quot;)} /&gt;
                            &lt;/label&gt;
                            &lt;div className=&quot;invalid-feedback d-block&quot;&gt;
                                {errors.age?.message}
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div className=&quot;input-group&quot;&gt;
                            &lt;label className=&quot;w-100&quot;&gt;Email
                                &lt;input type=&quot;text&quot; className=&quot;form-control&quot; {...register(&quot;email&quot;)} /&gt;
                            &lt;/label&gt;
                            &lt;div className=&quot;invalid-feedback d-block&quot;&gt;
                                {errors.email?.message}
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div className=&quot;input-group&quot;&gt;
                            &lt;label className=&quot;w-100&quot;&gt;Password
                                &lt;input type=&quot;password&quot; className=&quot;form-control&quot; {...register(&quot;password&quot;)} /&gt;
                            &lt;/label&gt;
                            &lt;div className=&quot;invalid-feedback d-block&quot;&gt;
                                {errors.password?.message}
                            &lt;/div&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div className=&quot;col-md-6 mb-6&quot;&gt;
                        &lt;button type=&quot;submit&quot; className=&quot;btn btn-outline-success w-100&quot;&gt;Send&lt;/button&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/form&gt;
        &lt;/&gt;
    )
}
</code></pre>				</div>
				</div>
				<div class="elementor-element elementor-element-085804e elementor-widget elementor-widget-text-editor" data-id="085804e" data-element_type="widget" data-e-type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
									<p>I highly recommend using <strong>React Hook Form</strong> combined with <strong>Yup</strong> validation in your daily work with <strong>React</strong>.</p>								</div>
				</div>
					</div>
				</div>
				</div><p>The post <a href="https://pawelmajewski.com/simplify-your-react-forms-with-react-hook-form-and-yup/">Simplify Your React Forms with React Hook Form and Yup</a> first appeared on <a href="https://pawelmajewski.com">Software Developer's Tour</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://pawelmajewski.com/simplify-your-react-forms-with-react-hook-form-and-yup/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
