No video

React Forms Full Tutorial - Validation, React-Hook-Form, Yup

Best Tech Resume Template: papermoontech....
Use code: PEDRO for 20% off ^
Here is the command I used to install all packages: yarn add react-hook-form yup @hookform/resolvers
Code: github.com/mac...
In this video I teach you guys how to build forms in react. I use the libraries YUP and React-Hook-Forms to help me.
-
🚀 Learn ReactJS By Building 6 Projects: codedamn.com/l...
💻 PedroTech Discord: / discord
-
Social
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Website: machadopedro.com
Twitter: / pedrotech_
Linkedin: / machadop1407
Instagram: / _pedro.machado_
Github: github.com/mac...
Email: machadop1407@gmail.com
Timestamps
00:00 | What we are building
03:01 | Implementation
Tags:
- React Forms
- Forms in React
- ReactJS Tutorial
- ReactJS and MySQL
- NodeJS Tutorial
- API Tutorial

Пікірлер: 165

  • @gotemperory4278
    @gotemperory42783 жыл бұрын

    what worked for me is: const { register, handleSubmit, formState: { errors } } = useForm({ resolver: yupResolver(schema), }); instead of const { register, handleSubmit, errors } = useForm({ resolver: yupResolver(schema), }); and {...register('password')} instead of ref={register}

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Appreciate it! This is the new updated version!

  • @hmsm5701

    @hmsm5701

    3 жыл бұрын

    thanks a lot

  • @akhiltheloquacioussoul

    @akhiltheloquacioussoul

    3 жыл бұрын

    Thank you so much :)

  • @andriitsvirko7296

    @andriitsvirko7296

    3 жыл бұрын

    thanks a lot!!!!!!!!!!!!!!

  • @TheRonron1994

    @TheRonron1994

    2 жыл бұрын

    I'm getting this error instead Error: Function components cannot have string refs. We recommend using useRef() instead.

  • @df15804
    @df158043 жыл бұрын

    It is amazing to see this kind of content coming from a Brazilian guy, thank you there

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Hahaha thank you so much! Brazil needs to grow in the programming community!

  • @monikabhardwaj9105
    @monikabhardwaj91053 жыл бұрын

    A very good tutorial. Because of the new version release there are few changes that we have to do. 1. Error is now a part of formState so use it like below instead of const{register, handleSubmit,errors} const{register,handleSubmit,formState: { errors }} =useForm({ resolver:yupResolver(schema), }); 2. replace ref={register} to {...register("phone_number")} , replace "phone_number" with the name of your field.

  • @ujjawalchatterjee

    @ujjawalchatterjee

    3 жыл бұрын

    Appreciate it

  • @sebastiandrozd233

    @sebastiandrozd233

    2 жыл бұрын

    +1

  • @ayjayaywhy

    @ayjayaywhy

    11 ай бұрын

    Appreciate it

  • @guythomas5391
    @guythomas53912 жыл бұрын

    This is an excellent tutorial, thank you! One small criticism - it's not good practice to rely solely on front end validation, so I would revise the comment in this video "You can safely make a fetch request... and it should be completely safe because you're only submitting the data if it passes through the layer of validation". Someone could easily craft a request via postman or something and submit direct to your server. Always employ server validation.

  • @linmus2370
    @linmus23703 жыл бұрын

    You're so badass! I'll go out on limb and say that your channel is gonna have millions of subscribers. I do have a feeling of that. The efforts you're exerting into the videos you're cranking out are gonna pay off. It's a top-tier channel. You're freaking killing it. Love from the US.

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Hahaha I love this kind of comments! Thank you so much! I really appreciate the support!

  • @fancyAlex1993
    @fancyAlex19933 жыл бұрын

    In v7, it should be like this , replace ref with an obj like this {errors.firstName?.message} Thank you for this tutorial. I was getting tired reading the react-hook-form documentation.

  • @ak2000_

    @ak2000_

    2 жыл бұрын

    TypeError: Cannot read properties of undefined (reading 'firstName')

  • @mpv756
    @mpv7562 жыл бұрын

    Great video! I'm just learning react. The course I was taking used redux-form \ redux. I was trying to do the right thing (I think) and make a radio button it's own component so it could be shared in any form. It was a nightmare because of all the state management between components. I never did get it to work. So I was ready to try something new, even if I can't make the radio button it's own component (I'm sure you can). A google search of what are the best libraries for forms got me to react-hook-forms, which led me here. Thank you so much for showing everything from beginning to end. Very helpful and useful.

  • @Mahdi-lz9wu
    @Mahdi-lz9wu3 жыл бұрын

    thank you, buddy, find a good solution after 3 days of struggling with form and validation. just react-hook-from had changed to version 7 and it needs some small change but this tutorial is absolutely brilliant.

  • @ayushdedhia25
    @ayushdedhia253 жыл бұрын

    Your tutorials are just amazing and easy to grasp the concept ❤️🔥

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Happy to hear that!

  • @anikinae
    @anikinae2 жыл бұрын

    perfect speach (not too slowly and not too fast) - thank you so much, it's very useful!

  • @iqra.manzoor4222
    @iqra.manzoor42222 жыл бұрын

    I am using the same code with react version 18.1.0.But it is not working, browser is displaying white screen.How can I resolve this issue?

  • @Trzimajewski
    @Trzimajewski2 жыл бұрын

    Mano, ótimo conteúdo, parabéns. Muito bom saber que existe conteúdo de qualidade assim e que é brasileiro que faz, te desejo muito sucesso.

  • @AnthonyCandaele
    @AnthonyCandaele2 жыл бұрын

    Thanks for this video, the combination of react-hook-form and yup is just what I need for the form validation in my next project.

  • @junjietan2668
    @junjietan26683 жыл бұрын

    Keep on going Pedro, your videos helps me a lot. Appreciate your hard work!

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Happy to hear that! This comments motivate me a lot!

  • @junjietan2668

    @junjietan2668

    3 жыл бұрын

    @@PedroTechnologies no worry pedro. Meanwhile, i have a barrier after working on the form. it is working fine in the form validation. however comes to form submission, the function was not working even though the password is matched. I noticed if i have remove the resolver from useform, it is working fine as the console will printed out the outcomes however the password and Cpassword have no validation. then, if i implment the resolver onsubmit function does not fire up at all. What's the problem? Many thanks.

  • @muradjadoon619

    @muradjadoon619

    Жыл бұрын

    @@PedroTechnologies I like your videos

  • @dedekinc
    @dedekinc2 жыл бұрын

    ./src/Components/Form.js Module not found: Can't resolve '@hookform/resolvers/yup' in 'C:\Users\uscr\Desktop\letreact\src\Components'

  • @amanbansal3928
    @amanbansal39283 жыл бұрын

    i got error : Could not install from "@hookform esolvers\yup" as it does not contain a package.json file...please help me!!

  • @Dan_ny

    @Dan_ny

    3 жыл бұрын

    npm install @hookform/resolvers

  • @DimmuBorgiry
    @DimmuBorgiry2 жыл бұрын

    thanks my friend, it was really a helpful video for me to get into react hook forms. keep up the good work

  • @adennis200
    @adennis2003 жыл бұрын

    Not gonna watch it right now cause no time but I'm gonna like it in advance

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Hahaha this makes me happy! Really appreciate the support!

  • @marbot9780
    @marbot97802 жыл бұрын

    Hello Pedro, I am a big fan of your videos here! Thanks for this one - it is amazing! Could you please also show how to split the form here into a multi-form (at least 3 input steps) and everything then still works - including validation!? That you can e.g. only jump on if everything is correct and that you don't lose any values when jumping back! There are already videos about it - but they are all incomplete or incorrect! Thanks in advance! Best regards Markus

  • @anshunarayan8056
    @anshunarayan805610 ай бұрын

    Although you are speaking in an american accent but your lectures are too easy to understand😊

  • @perfectionist2518
    @perfectionist2518 Жыл бұрын

    mate, you got a talent! thank you, it was simple and clear

  • @andrscrrn
    @andrscrrn2 жыл бұрын

    Very clear explanantion! Thanks Pedro!

  • @Jiji-lo3zs
    @Jiji-lo3zs Жыл бұрын

    I finally understood react-hook-forms. Thankyou 🙂

  • @marimuthur9456
    @marimuthur94562 жыл бұрын

    Extraordinary explanation thank you so much for your knowledge sharing 😊👌🏼🙏🏼 try to post the video how to bind the form data back to the input fields using yup

  • @dennisbelio6470
    @dennisbelio64703 жыл бұрын

    Thank you PedroTech for this wonderful resource!

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Glad it was helpful!

  • @sinaukode
    @sinaukode3 жыл бұрын

    Thanks, it's really helpful for me who just started to learn react stuff

  • @caikhenrik10
    @caikhenrik103 жыл бұрын

    Pedro, muito bom vídeo! Mais um inscrito pra ti... Uma sugestão pro próximo vídeo, fazer validação de arquivos com o yup e react hook form... verificar se o arquivo é muito longo, formato, etc... Ajudaria bastante! Top

  • @caikhenrik10

    @caikhenrik10

    3 жыл бұрын

    No caso upload de arquivos*

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Obrigado! Você quer dizer validar arquivos que sao uploaded?

  • @caikhenrik10

    @caikhenrik10

    3 жыл бұрын

    @@PedroTechnologies isso! Por exemplo validar se o arquivo é uma imagem, e se a imagem não excede determinada altura e largura por exemplo, seria top!

  • @bluebill1049
    @bluebill10493 жыл бұрын

    Thank you very much for putting up this video tutorial!

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Glad it was helpful!!

  • @wilhelm.reeves
    @wilhelm.reeves2 жыл бұрын

    Your videos are very easy to follow. Thank you 🥂

  • @benitomunga4143
    @benitomunga4143 Жыл бұрын

    Getting Uncaught TypeError: path.split is not a function in react:- react-hook-form updated to 7.0.0 from 6.X.X and has breaking changes: You have to replace all ref={register} with {...register('value_name')}👍

  • @brosethkator7246
    @brosethkator72462 жыл бұрын

    Hi PedroTech, what extension you use to detect file size when import library? Eg: import React from "react"; this part -> "7. 2K (gzipped: 2.9K) " Thanks.

  • @munisazatov7416

    @munisazatov7416

    2 жыл бұрын

    'Import cost'

  • @gotemperory4278
    @gotemperory42783 жыл бұрын

    I am having the same issue : Its Giving an error '' TypeError: Cannot read property 'firstName' of undefined '' , so I had to do "{...register('firstName')}" instead of ref={register}. But still says Also not displaying errors, even if I copy paste all of your code. It looks like errors is undefined - "Cannot read property 'firstName' of undefined"

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    THank you! The library updated after I made the video so now its outdated!

  • @husseinkizz

    @husseinkizz

    3 жыл бұрын

    @@PedroTechnologies I have the same issue but gonna look into the documentation if that's the case but don't you consider remaking your tutorials to updates over time? Anyways thanks we love your content!

  • @jenslegrou
    @jenslegrou3 жыл бұрын

    This is gold. Thank you so much!

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Glad it was helpful!

  • @anisuzzaman3723
    @anisuzzaman37232 жыл бұрын

    If i use react hook from need to click submit button two times otherwise not work and if i give any default value in input field without mouse cursor pointer click those input field data not take or pass.could you tell me why ????

  • @mohamedabdulqadir2917
    @mohamedabdulqadir29173 жыл бұрын

    Your tutorials really amazing, thank you Pedro

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Glad you like them!

  • @harshitverma4480
    @harshitverma44802 жыл бұрын

    Very clear n concise explanation.

  • @vinayr6232

    @vinayr6232

    2 жыл бұрын

    Hey Harshit! Glad you liked the video.....would you be interested in exploring opportunities in web development?

  • @anmolgarg7038
    @anmolgarg7038 Жыл бұрын

    Amazing tutorial, really well described. Loved it .

  • @RahulKumar-qu1if
    @RahulKumar-qu1if Жыл бұрын

    Can you please tell how i get the min value from the field itself not the hard-coded in the schema

  • @hamidrezahassanzadeh246
    @hamidrezahassanzadeh2462 жыл бұрын

    Hi dear Pedro! Actually I want to thank you for this really really well-described content , you helped me a lot my bro ❤

  • @thiagoleobons390
    @thiagoleobons3903 жыл бұрын

    Maneiro o canal cara. Parabens!

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Obrigado, fico feliz!

  • @ThColinPereira
    @ThColinPereira3 жыл бұрын

    This helped me a lot, thanks Pedro!

  • @MrNik0l0z
    @MrNik0l0z Жыл бұрын

    from where did ref come from? when i type it the way you do, it gives me an error

  • @hamdihawari
    @hamdihawari Жыл бұрын

    Please tell me how do I clean the values after submitting :) something like reset

  • @CarlWicker
    @CarlWicker2 жыл бұрын

    THanks for this, great tutorial.

  • @minsungsuh3872
    @minsungsuh3872 Жыл бұрын

    Thank you for this useful video! Is there a way to style the error messages?

  • @brijeshp1878
    @brijeshp1878 Жыл бұрын

    hello from india iam getting error like this = Cannot read properties of undefined (reading 'firstName')

  • @frontendwithsalimi

    @frontendwithsalimi

    10 ай бұрын

    use the useForm like this const { register, handleSubmit, formState:{errors} } = useForm({ resolver: yupResolver(userSchema), });

  • @jamesfreeman1530
    @jamesfreeman15302 жыл бұрын

    Hi Pedro, how can I pass the error response from express/mongoose to yup schema to validate email uniqueness? should I put the the error response to state and from there use the state to validate from yup schema? newbie here and kind of lost. thanks

  • @deepakratra77
    @deepakratra77 Жыл бұрын

    How to do dependent validation. example if first name is predo then only last name is mandatory ?

  • @safintheship
    @safintheship2 жыл бұрын

    thank you so much dude

  • @skverskk
    @skverskk2 жыл бұрын

    Well done and easy to understand. Thx

  • @Marcus-09
    @Marcus-092 жыл бұрын

    hi Pedro, amazing video as always. I have a question: how can i validate a disabled input where the value and placeholder is defined by props? Or there is no needed?

  • @antenehyehalem5963
    @antenehyehalem59633 жыл бұрын

    heyy another awesome video from hero keep doing it

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Thank you! Really appreciate the support!

  • @kofinartey116
    @kofinartey1163 жыл бұрын

    Thanks a lot for this sir. You helped out a brother

  • @thrivingproject1920
    @thrivingproject19202 жыл бұрын

    Hey, great vid; what's the extension you use that formats the JS document around 18:13?

  • @aneeqrehman4138
    @aneeqrehman41383 жыл бұрын

    thumbs UP!.... Q# what is the best way to design our components in a project......either we use styled-componnets,scss or css......?

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    I like to use styled-components! There is no best way, it is all about preference!

  • @aneeqrehman4138

    @aneeqrehman4138

    3 жыл бұрын

    @@PedroTechnologies plz share the link where you have design a full dynamic tamplate using style...

  • @fionagonza8829
    @fionagonza8829 Жыл бұрын

    Thank you Pedro.

  • @buihuyhung6490
    @buihuyhung64902 жыл бұрын

    Great tutorial, can you a tutoral on multi step form with react-hook-form and yup

  • @kasiakordys266
    @kasiakordys266 Жыл бұрын

    great tutorial! Thank you a lot

  • @deepalakshmip5520
    @deepalakshmip55202 жыл бұрын

    Very clean ...Superb

  • @thru_and_thru
    @thru_and_thru2 жыл бұрын

    Awesome tutorial, thanks so much!

  • @MSEIN2303
    @MSEIN2303 Жыл бұрын

    The best tutorial. thanks a lot

  • @maicolfg
    @maicolfg2 жыл бұрын

    Gracias Pedro, super bueno el tutorial, facil de entender.

  • @akiij
    @akiij3 жыл бұрын

    what extension is that you're using where you get syntax definitions while typing? anyone knows?

  • @thyago8062
    @thyago80623 жыл бұрын

    Amazing! Could you make a video about masked inputs with React? Thanks!

  • @lesharper8751
    @lesharper87512 жыл бұрын

    I don't understand. Why use yup if react-hook-form has built-in validation that works fine and you don't need extra libraries loading the bundle

  • @minhthongvo5989
    @minhthongvo59893 жыл бұрын

    Thank you very much Pedro!!!

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    My pleasure!

  • @yashuapervez1533
    @yashuapervez15332 жыл бұрын

    great tutorial, it really helped

  • @AMoktar
    @AMoktar2 жыл бұрын

    Amazing. Thanks bro

  • @hamzamuhammad2967
    @hamzamuhammad29673 жыл бұрын

    Love your content keep it up.

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Glad you enjoy it!

  • @moisesdelarosa3843
    @moisesdelarosa38432 жыл бұрын

    Hello, does anybody know which color theme is he using?

  • @Cmxmxmmx7
    @Cmxmxmmx72 жыл бұрын

    errors.firstName?.message is this typescript? Why there is a question mark after firstName? Also I tried to add min(8) characters to password field but error is not showing up for some reason.

  • @denmccormik7654

    @denmccormik7654

    2 жыл бұрын

    syntax has changed a bit, also "?" - that is javascript, check the docs

  • @cryptoboy1461
    @cryptoboy14612 жыл бұрын

    Great tutorial! It would be more helpful if you used different form types.

  • @khanhhq2044
    @khanhhq20443 жыл бұрын

    how to get the value to change input, without onSubmit?

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    You can create some states and change them on the onChange property!

  • @johnconnor9787
    @johnconnor97872 жыл бұрын

    How can we validate input type="file" with yup

  • @hienqngo
    @hienqngo2 жыл бұрын

    Thanks!

  • @PedroTechnologies

    @PedroTechnologies

    2 жыл бұрын

    Thank you for the support!

  • @mralex6543
    @mralex65432 жыл бұрын

    Have you tried required() for Confirm Password?

  • @DioArsya
    @DioArsya2 жыл бұрын

    Easier to use react hook form and typescript then create an interface and attach it as generic to the useForm hook. And also Yup is very large in size

  • @sreekanthvadassery8288
    @sreekanthvadassery82882 жыл бұрын

    Superb!!

  • @RealEstate3D
    @RealEstate3D3 жыл бұрын

    Unfortunately we have already react-hok-form v7 out.

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Damn, hope it didn't change a lot!

  • @TungPham-hn1lr
    @TungPham-hn1lr3 жыл бұрын

    I cannot install @hookform/resolvers/yup and I saw that you crashed on it as well. How did you please import this package?

  • @lyubomirdias5465

    @lyubomirdias5465

    3 жыл бұрын

    just add @ hookform / resolvers ---- than import yupResolver from "@hookform/resolvers/yup"

  • @CHANNELGIVEWAY
    @CHANNELGIVEWAY2 жыл бұрын

    nice amazing thank you

  • @mahendranath2504
    @mahendranath2504 Жыл бұрын

    Thank you so much 👍💕👌🙏🤞✌

  • @Davi-wv8mi
    @Davi-wv8mi2 жыл бұрын

    Nice Pedro

  • @ruslanpascoal9247
    @ruslanpascoal92472 жыл бұрын

    muito bom pedro!

  • @caiofelixreis8970
    @caiofelixreis89702 жыл бұрын

    brazil é cabuloso credo 👏🏾

  • @nishadsandilya6653
    @nishadsandilya66533 жыл бұрын

    I cannot get the errors to work, even after formState:{errors}. what to do?

  • @gaurav8113

    @gaurav8113

    2 жыл бұрын

    Hi Nishad! hope your doubt got resolved. Are you a self-taught programmer?

  • @softblood1941
    @softblood19413 жыл бұрын

    very helpful !

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Glad it was helpful!

  • @nargizgasanova6222
    @nargizgasanova62222 жыл бұрын

    thanks

  • @DarkShadow00972
    @DarkShadow009723 жыл бұрын

    Nice, Bro where r u from buddy

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Thank you! I am from Brazil!

  • @tagalogmovierecapspoiler
    @tagalogmovierecapspoiler3 жыл бұрын

    you save me

  • @ajantica
    @ajantica2 жыл бұрын

    I got no output, following all the steps you showed

  • @Isaz63
    @Isaz632 жыл бұрын

    Hey Pedro, excellent series of videos on React. Thanks. Su nombre y apellidos son latinos pero su acento no, cuales su ascendencia? Gracias de nuevo!

  • @Ibrahim-ir6ft
    @Ibrahim-ir6ft Жыл бұрын

    Exellent video

  • @joaopedromonteiroperaro3237
    @joaopedromonteiroperaro32373 жыл бұрын

    muito bom cara!

  • @abdelrahmanmahmoud891
    @abdelrahmanmahmoud8912 жыл бұрын

    thanxxx

  • @knuckless__
    @knuckless__ Жыл бұрын

    excellent

  • @mohakmaheshwari8756
    @mohakmaheshwari87563 жыл бұрын

    Its Giving an error '' TypeError: Cannot read property 'fname' of undefined '' I have used fname everywhere. Checked it Twice Please Help !!!

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Hey, I don't think I used a variable called fname in the tutorial! I created a property called firstName, maybe the issue is there! Let me knoow if it fixes!

  • @mohakmaheshwari8756

    @mohakmaheshwari8756

    3 жыл бұрын

    @@PedroTechnologies i used fname instead of firstName..... and used it same through out the entire code ... it's still not working.... maybe its version mismatch i don't know And when i use ref={register} it gives me bunch of errors so i had to use {... register ('fname')}

  • @ShahbazKhan-zl2zt
    @ShahbazKhan-zl2zt3 жыл бұрын

    Getting this error anyone please help me Unexpected token: {errors.email?.message} ^

  • @robiparvez
    @robiparvez3 жыл бұрын

    nice work

  • @PedroTechnologies

    @PedroTechnologies

    3 жыл бұрын

    Thank you! Cheers!

  • @mohamedyoussef8835
    @mohamedyoussef88352 жыл бұрын

    Awesome explanation... thank you ++++++++++++++++++++++++++