How to use REACT HOOK FORM with TYPESCRIPT

Sdílet
Vložit
  • čas přidán 30. 07. 2020
  • 📘New Course: Build full-stack React Typescript applications tsreact.maksimivanov.com/s/ytd
    Today we learn how to use React Hook Form with Typescript. I'll create a react application using create react app with typescript template and then i'll define a form that will be handled by react-hook-form
    🐦 Twitter: / ivanov_dev
    I write about React and TypeScript there
    Code: github.com/satansdeer/rhf-ts
    Where to find me:
    Discord: / discord

Komentáře • 27

  • @serdcevputi
    @serdcevputi Před 3 lety

    Спасибо Макс! Хорошо объясняешь!

  • @faradniftaly8893
    @faradniftaly8893 Před 3 lety

    Great video very clean explanation ... Thx!

  • @AntonioBrandao
    @AntonioBrandao Před 4 lety +2

    Lol this channel is ridiculously underviewed. Keep it up though

  • @amariliscamargo
    @amariliscamargo Před 2 lety

    Muito obrigada!!!!! Me ajudou demais 😊

  • @bukenoff
    @bukenoff Před 3 lety +2

    I like how you make your videos. Straight to the point and very instructive. No nonsense.
    Question: should you wrap handleSubmit inside useCallback, like every other function inside functional component?

    • @satansdeer1
      @satansdeer1  Před 3 lety +1

      Serik B thanks, no don't do it preliminarily, most likely you don't need it. Only do it if you know it will be a performance concern otherwise. Usually it's not

  • @pixelxchange
    @pixelxchange Před 2 lety

    Your video help me a lot Thank you so much

  • @diegor5805
    @diegor5805 Před 3 lety

    Thank you very mouch!

  • @battmarn
    @battmarn Před 3 lety

    This just saved my ass. Thanks man

  • @CushiMusi1
    @CushiMusi1 Před 4 lety +4

    Love your videos! could you explain about decorators in typescript ?

  • @Kedarbhokare
    @Kedarbhokare Před 4 lety +1

    Thanks for the video, can you please make video on cloud function for server side pagination, use firebase if possible, and how to change pages on client side, thanks in advance

  • @mykemacedo696
    @mykemacedo696 Před 2 lety

    Vlw, me ajudou muito

  • @rickyalmeida
    @rickyalmeida Před 4 lety

    Hi, Maskim. Great content as usual, thank you! Let me ask you something, what is the name of your theme on VSCode?

    • @satansdeer1
      @satansdeer1  Před 4 lety +2

      Ricky Almeida ocean something something from the material theme

  • @aaronvasilev2371
    @aaronvasilev2371 Před 3 lety

    Макс

  • @thomaschalanson8643
    @thomaschalanson8643 Před 2 lety

    Hello and thanks for your tutorial because i'm begin with Typescript.
    I try to upload images file with an input file but i got this error and i don't understand how to fix it ?
    can you say me what's wrong in my code please ?
    Type '(event: FormEventHandler) => void' is not assignable to type 'FormEventHandler'.
    Property 'target' does not exist on type 'FormEventHandler'.
    here my function :
    function formHandler(event: React.FormEventHandler) {
    event.preventDefault();
    const selectedImg = event.target.files && event.target.files[0];
    console.log(selectedImg);
    if (selectedImg && Types.includes(selectedImg.type)) {
    setFile(selectedImg);
    setError("");
    } else {
    setFile(null);
    setError("Please select an file file like png or jpg or svg or webp");
    }
    uploadfiles(file);
    setShowProgress(!showProgress);
    }

  • @maisaan9075
    @maisaan9075 Před 2 lety

    How would you do this with reusable components? With the ability to pass required, patterns, min, max etc

    • @justirva
      @justirva Před 2 lety

      You should create the reusbale form component first. Then just use the reusable form with the hook useForm

  • @trumpa94
    @trumpa94 Před 3 lety +4

    This no loger works :(
    You get an error when you try to place ref on an element

    • @ilianekrasov4807
      @ilianekrasov4807 Před 3 lety

      same shit... did you figure it out, how to handle this?

    • @trumpa94
      @trumpa94 Před 3 lety

      @@ilianekrasov4807 i found some custom solution. just google react hook form custom reducer, smthng like that

    • @iPingOi
      @iPingOi Před 2 lety

      {...register('password', {
      required: true })} -> name="password"

    • @NK-xk6bb
      @NK-xk6bb Před 2 lety +5

      I had the same issue and i found that replacing the input element following this convention worked!
      const {register, handleSubmit, formState: {errors} } = useForm()

    • @Jonsy
      @Jonsy Před rokem

      @@NK-xk6bb You just saved me so much time man thank you!!!

  • @almukhametovar
    @almukhametovar Před 2 lety

    V6

  • @Pareshbpatel
    @Pareshbpatel Před rokem

    {{2023-03-19}