React Dynamic Form Tutorial | react-hook-form & zod

Поделиться
HTML-код
  • Опубликовано: 12 сен 2024

Комментарии • 28

  • @tosheen20
    @tosheen20 2 года назад +6

    This is a great content, well done. Could you create a slightly complex examle. Lets say there is a drop down and first validation rule is that an option must be selected, it can not be null which is a first option. Depending on a selection different fields are displayed according to some logic. If for example email is selected from the drop down additional email field is displayed and it must be valid email. If telephone is selected then it must be valid phone number etc. I am curious to know how will zod schema look in that case because we have default null state for the drop down and in the case we have more drop downs with different "branching". Thank you.

  • @animanamit7543
    @animanamit7543 2 года назад +3

    Great tutorial!! Your videos are really helpful while I'm learning to use Zod :)

  • @socialultra7219
    @socialultra7219 8 месяцев назад

    cheers dude, I was struggling on this problem for a while, your content helped immensely

    • @AustinShelby
      @AustinShelby  8 месяцев назад

      Glat to have helped you solve your problem!

  • @koreandude
    @koreandude Год назад

    Appreciate the content Austin, subbed and liked! Hope you can continue to create more videos like this

  • @LuisLarreaJr
    @LuisLarreaJr 6 месяцев назад +1

    Great example. I had something similar when product had the bright idea to still show the fields but disabled. Apparently this really complicates things since now you have to disable the validation rules from triggering on disabled fields.

  • @athefirstletteraofthealpha769
    @athefirstletteraofthealpha769 Год назад

    Thank you, Austin. Your tutorial is very clear and helpful.

  • @HariKrishna-qh5zp
    @HariKrishna-qh5zp Год назад +2

    its a great tutorial Austin, however I strongly feel you must have adopted some design library as the implementation of Tailwind CSS made this look so clumsy and not on the point to what the video trying to convey. I mostly prefer MUI or Chakra UI for simple and elegant design of forms.

    • @AustinShelby
      @AustinShelby  Год назад +1

      Thanks for watching Hari. While UI libraries like Material UI are useful for creating good looking designs quickly, they cause some extra complexity when integrating form libraries such as react-hook-form.

    • @HariKrishna-qh5zp
      @HariKrishna-qh5zp Год назад

      @@AustinShelby Thanks so much for your response. You are absolutely right. While I was working on a dynamic form similar to the one in the video, I had to disable form fields after checkbox however @Mui latest version's Checkbox is not allowing that functionality.

  • @user-se6mi3fe8w
    @user-se6mi3fe8w Месяц назад

    Great tutorial. If I need to store objects removed from useFieldArray remove method to another array for subsequent use. How can I achieve this?

  • @johnc0de
    @johnc0de Год назад

    Amazing! Thank you for the content!

  • @kakun7238
    @kakun7238 2 месяца назад

    amazing thank you for this could you make one for the fields coming from the db or a json file

  • @arturpawelski321
    @arturpawelski321 Год назад

    thank you for help ,you are great teacher❤

  • @rjtdas
    @rjtdas Год назад

    Clean !😀... Thanks

  • @miketepes8208
    @miketepes8208 Год назад

    Thank you very much Sir. I learned a lot. I applied this to checkout page where checkbox is biling address is same with shipping address or not. Thank you very much

    • @AustinShelby
      @AustinShelby  Год назад

      Hey Mike it's awesome to hear that this video helped you! Thanks for watching.

  • @rastaray6401
    @rastaray6401 Год назад +1

    How do you access errors on the email field? Accessing formstate.errors.email results in a "property does not exist" TypeScript error

    • @AustinShelby
      @AustinShelby  Год назад +3

      TypeScript is correct in this case. If the checkbox is not checked there won't be a property email in the formState.errors object. To fix this, you have to first check if the object has the email key like this:
      "email" in formState.errors && formState.errors.email

  • @andrescuberosalas
    @andrescuberosalas Год назад

    This is great, but what if the form has over 20 fields, I would need to create a copy of it for every version, is there a more 'versatile' way of achieving this? Maybe when setting the definition of a type in the schema, can I co-require a field, instead of creating different possible versions of it? I'm new to zod as you can tell...

    • @andrescuberosalas
      @andrescuberosalas Год назад

      Nevermind, I found a more dynamic way to do it, just creating the z.object with the diff, and merging the base schema, so I don't have to create copies for every version.

    • @AustinShelby
      @AustinShelby  Год назад +1

      @@andrescuberosalas I'm glad you found the solution for it and thanks for sharing it with everyone 👍

    • @jlkinley
      @jlkinley Месяц назад

      @@andrescuberosalas Can you give an example of what you did here? I might be able to use that for my issue.

  • @Foused87
    @Foused87 Год назад

    Why you stopped making videos? Your videos are so helpful!

    • @AustinShelby
      @AustinShelby  Год назад

      Honestly just pure laziness. I should just probably get back to it as people seem to be enjoying these videos.

  • @jlkinley
    @jlkinley Месяц назад

    did you delete my comment? Jeesh.

    • @AustinShelby
      @AustinShelby  27 дней назад

      I did not. I saw your comment. It was something about extending a more complex schema based on a drop down such as a subscription, right?