V6 - React Hook Form - building dynamic form (Field Array)

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ •

  • @bencodes
    @bencodes 3 роки тому +10

    You sir, are an amazing human for making forms so easy!

  • @JojoNicho
    @JojoNicho 4 роки тому +2

    Thanks for the great video! I can already see real-life scenarios where this feature would be handy. Also noticed your improved English. Keep it up, I'm a fan!

  • @chaddpoggenpoel6727
    @chaddpoggenpoel6727 4 роки тому +1

    Amazing video. Super valuable information. Will definitely play with it and ask in comments if I have a question. Not sure if I will have any though. Explanation was on point and concise! Keep up the good work! Thank you and God bless you !

  • @mvssss_
    @mvssss_ 2 роки тому +1

    Thank you very much for this video!

    • @bluebill1049
      @bluebill1049  2 роки тому +1

      Thanks, this is an old version, maybe it's worth checking v7 instead.

  • @RahdixCloudNine
    @RahdixCloudNine 2 роки тому +1

    subscribed and many thanks Bill, amazing!

  • @BezalelTheCraftsman
    @BezalelTheCraftsman Рік тому +1

    Thanks man! Good stuff 👍

    • @bluebill1049
      @bluebill1049  Рік тому +1

      Please checkout the new version v7, v6 is 2 years behind.

  • @rohithsrivathsav6110
    @rohithsrivathsav6110 4 роки тому +1

    Awesome explanation, subscribed!

  • @DeepakKapiswe
    @DeepakKapiswe 4 роки тому +1

    Great and helpful Video, Thanks for sharing

  • @aimanjaffer
    @aimanjaffer 3 роки тому +1

    What's the use of while using useFieldArray forms

  • @billzhou8686
    @billzhou8686 3 роки тому +1

    So Coooo...ooool. Love 👍

  • @Ady567
    @Ady567 4 роки тому +1

    Thanks for the demo video. I am stuck with nested dynamic form (Same as your form but with one more append for specific field), please suggest something for this.

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      take a look at the example folder, there is an example of array of array

  • @tbass.p3480
    @tbass.p3480 3 роки тому +1

    you are a life saver, thank you! Me and my dificulty to understand documentations ahhhh... now my problem changed: "how can i made a update form with it? populating a list with a json and allow the user to edit it anyway?"

  • @zhalux19
    @zhalux19 3 роки тому +1

    Can you add yup schema validation to this? Noticed the array abject shape validation did not work for version react hook form version 6

  • @asimhafeezz
    @asimhafeezz 4 роки тому +1

    it’s awesome, thanku ❤️.

  • @turin1100
    @turin1100 2 роки тому

    How can i set empty object into fields array on init?

  • @sergio201083
    @sergio201083 4 роки тому

    Hi Bill, could you prepare a demo showing how to bind the data from the Redux storage with useFieldArray? I'm having some problems with it. Thank you. Great Video and Thank you for you helping.

  • @danielpreza4159
    @danielpreza4159 4 роки тому +1

    thank you for the video but I have a question, how can I show by default elements?

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      use `defaultValues` at useForm, or you can also use `reset` API at `useEffect`.

    • @danielpreza4159
      @danielpreza4159 4 роки тому +1

      @@bluebill1049 can you give me an example using defaultValues at useForm please
      because my input name is like this: name={`checker[${ index }].name`}

  • @joe-sydney-au
    @joe-sydney-au 2 роки тому +1

    Has the API for react-hook-form v.7 changed with respect to refs ? I get errors on the line ref={register()} inside input, what's going on?

  • @ravendonly1
    @ravendonly1 4 роки тому +1

    THANK YOU SO MUCH!

    • @bluebill1049
      @bluebill1049  4 роки тому

      YOU ARE WELCOME! ❤️

    • @ravendonly1
      @ravendonly1 4 роки тому

      @@bluebill1049 how can i apply nested default value in second append

    • @ravendonly1
      @ravendonly1 4 роки тому

      codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-x7btr?file=/src/nestedFieldArray.js

    • @bluebill1049
      @bluebill1049  4 роки тому

      @@ravendonly1 you can use append at the nested child with at useEffect, or you can use setValue('test', []) to update the entire field array.

  • @ramonmaciel6230
    @ramonmaciel6230 4 роки тому +1

    Amazing video, amazing lib! A little doubt, how I render a input components before run the append?

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      what's the reason to re-render your input?

    • @ramonmaciel6230
      @ramonmaciel6230 4 роки тому +1

      @@bluebill1049 Hi! This isn't a re-render, I guess. I just need to have an input before clicking on append button. I don't know if was clear 😅

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      @@ramonmaciel6230 check the doc for `defaultValues`, there is an example in the doc as well.

  • @rujalsapkota3824
    @rujalsapkota3824 4 роки тому +1

    How to add error.message for each field ???? I am unable to use optional chaining

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      errors.test && errors.test.message (if you can't use optional chaining)

    • @rujalsapkota3824
      @rujalsapkota3824 4 роки тому +1

      ​@@bluebill1049 thanks

  • @guy_in_shoes
    @guy_in_shoes 2 роки тому

    This may just apply to V7, but I found that instead of just doing {...register()}, I had to do {...register("name")} to see any values in my onSubmit array.

  • @danielperez3559
    @danielperez3559 3 роки тому

    Gracias!

  • @abelmurua6980
    @abelmurua6980 2 роки тому

    Great video, thanks. I have a typescript error. When I enter 'name' as the parameter for useFieldArray({}) I get this typescript error: ******** "Type 'string' is not assignable to type 'never'. The expected type comes from property 'name' which is declared here on type 'UseFieldArrayProps'" ******** any idea why? When I remove my type of from useForm(); this error disappears

  • @guillaumek8029
    @guillaumek8029 4 роки тому +2

    Thank you !
    Im not sure the 'remove' methods provided by the lib is really removing at specified index tho. For me ths this doesn't work at all, it just remove the last of the array ..
    EDIT: I'm a noob. Please do not use as the key the index of the map when you iterate over you inputs. There is an 'id' property auto generated in your item that you must use as the key. At least, it's how i got it working

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      Have a play this one: codesandbox.io/s/react-hook-form-usefieldarray-vy8fv

    • @guillaumek8029
      @guillaumek8029 4 роки тому

      @@bluebill1049 I saw you respond to everyone on every forums... and now even on a YT channel, now that's dedication ! Thank you so much :)

    • @bluebill1049
      @bluebill1049  4 роки тому

      It's a passion to make something work for us (developers).

    • @jackhoang5019
      @jackhoang5019 3 роки тому +2

      @@bluebill1049 you know what? I subscribed your channel after reading this one "It's a passion to make something work for us (developers)."

    • @bluebill1049
      @bluebill1049  3 роки тому

      @@jackhoang5019 Thanks, Jack.

  • @Evkayne
    @Evkayne 4 роки тому +1

    amazing

  • @bpark765
    @bpark765 4 роки тому +1

    Hey Bill, is it possible to use the hook multiple times in a form?

    • @bluebill1049
      @bluebill1049  4 роки тому

      YES :)

    • @bpark765
      @bpark765 4 роки тому

      @@bluebill1049 do you mean by separating form fields into their own components and calling the hook in each of them? or is there a way to call the hook multiple times within 1 component?

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      @@bpark765 take a look at this example: codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-x7btr

    • @bpark765
      @bpark765 4 роки тому +1

      @@bluebill1049 Exactly what I was looking for! You're the best 👍

  • @wolixe
    @wolixe 3 роки тому

    What if I want to store the content directly in an array instead of in Objects.
    "names" : [
    "John",
    "Steve
    ]

  • @rujalsapkota3824
    @rujalsapkota3824 4 роки тому +1

    Could you please tell me how to set defaultValues through condition ??
    defaultValue={editMode ? 'Hi':' '}
    its not working

  • @entertainmentstack2518
    @entertainmentstack2518 3 роки тому

    Hi, I have a doubt, If the default values has a object data
    For eg: defaultValues: {
    "recipeTags": {
    "mainIngredient": ["Rice"],
    "course": ["All-day"],
    "cuisine": ["Chinese"]
    }
    }
    Now I want to loop :"recipeTags" using UseFieldArray. Is it possible?

    • @bluebill1049
      @bluebill1049  3 роки тому

      it's possible but, recipeTags should be an array as well.

  • @Max-xp3tf
    @Max-xp3tf 3 роки тому

    Hello thank you for this awesome video. I really love the library . I just have a question if someone can help me. I'm using the version 7 at the moment but I think the logic pretty much the same. There is my question:
    Is it okay to leave the append function with an empty object: append({})
    ..or should I always give the default values inside of it?
    I suppose that if I don't, it wil just pick the defaultValues from each individual inputs? I'm a little bit confused because in the doc, the examples always specifies them in the append fuction, even if there is also defaultValues present in each input.

  • @mahendranath2504
    @mahendranath2504 4 роки тому +1

    Thank you so much very helpful, can you increase the voice, it very low, and can you zoom your screen bigger, it a very small letter, pls

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      sorry about that, I will make sure to improve that next time. I am not a professional UA-camr, but i am learning my way through. Thanks

  • @JesseQuickEats
    @JesseQuickEats 4 роки тому +1

    Can you show us how to handle nested data? ex: instead if "name":"Hello" How can we make change to "Name": { "firstName": "Hello", "lastName": "World"}, "Type":"test" etc...

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      name="yourDetails.firstName"

    • @JesseQuickEats
      @JesseQuickEats 4 роки тому

      @@bluebill1049 Hello Bill, Can you give a quick example on Nested arrays Ex: "Name": [{ "firstName": "Hello", "lastName": "World"}], "Type:"newTest". is there a video I can follow for this
      ?

    • @bluebill1049
      @bluebill1049  4 роки тому

      @@JesseQuickEats take a look at the hook form repo, there is an example in the examples folder.

  • @sheikhmuhammedshoaib1124
    @sheikhmuhammedshoaib1124 4 роки тому +1

    How to populate arrayfield with data

  • @chaitanyasagar7432
    @chaitanyasagar7432 2 роки тому

    On click how to reset only one form in the fields array and leave the
    rest as it is…

    • @bluebill1049
      @bluebill1049  2 роки тому

      reset({
      ...getValues(),
      newDate: 'test'
      })

  • @MrFawads
    @MrFawads 3 роки тому

    Please use an external microphone.

  • @Emuu-r6o
    @Emuu-r6o 3 роки тому

    funny how much the battery percentage bothers me

  • @berlino5563
    @berlino5563 4 роки тому

    Poor quality video, it is a problem, i can’t read

    • @bluebill1049
      @bluebill1049  4 роки тому +1

      It's still processing for HD.

    • @bluebill1049
      @bluebill1049  4 роки тому +2

      It's 4K, that's why taking a while to process.