Giter Site home page Giter Site logo

Comments (20)

matiushariman avatar matiushariman commented on July 19, 2024 2

OK, strange that it works on the codesandbox but not in my project. Perhaps due to version differences or some bugs in my app. I'll double check ASAP.
https://codesandbox.io/s/react-bb21n

Sure, star it is. :)

from input.

matiushariman avatar matiushariman commented on July 19, 2024 1

@bluebill1049 done.

Just to update you, I can confirm that upgrading to the latest release solve the formState issue.
And sorry for being off topic, what do you think is the best way to do on mount validation? So far I use a custom register to do it (passing a callback func to validate)

https://react-hook-form.com/api#register

<input
  name="test"
  ref={
    register({
      validate: value => value === '1'
    })
  }
/>

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

https://codesandbox.io/s/react-hook-form-number-format-x58pw

from input.

matiushariman avatar matiushariman commented on July 19, 2024

thanks @bluebill1049 , that's what I was looking for.

big fan of RHF by the way, I will close this. Thanks!

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

No worries @matiushariman thanks mate :)

from input.

matiushariman avatar matiushariman commented on July 19, 2024

@bluebill1049 my bad, just one more Q if you don't mind.
Possible to do onChange validation with RHFI?
As per docs I believe we can set mode as onChange in either one or both useForm and RHFInput levels. But that does not seem to trigger the validation when changing the value of RHFInput

https://codesandbox.io/embed/react-hook-form-number-format-1g8p1

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

I will take a look at it :)

from input.

matiushariman avatar matiushariman commented on July 19, 2024

@bluebill1049 thanks!

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

hey @matiushariman the next patch will solve this problem.

https://codesandbox.io/s/react-2igx7

from input.

matiushariman avatar matiushariman commented on July 19, 2024

awesome, will be waiting for that @bluebill1049 . Thanks!

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

it's released :) let me know how it goes.

from input.

matiushariman avatar matiushariman commented on July 19, 2024

@bluebill1049 yup, it works. Thanks

I notice another thing. Seems like while using RHFI in onChange mode, input change won't affect RHF formState at all. It will be triggered only on submit.
The issue is there is no way to track the changes in formState (dirty, touched, etc) when changing the value.

Wondering if you're purposely doing it, and if there's any workaround for that.

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

looks like it's a bug. you have a codesandbox for this?

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

also asking a favor here, if you find RHF is useful. please consider leave us a star to support :)

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

thanks @matiushariman maybe try to get the latest version for both RHF and RHFInput. see if that solves the problem.

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

thanks a lot of the star, could you please star the main repo https://github.com/react-hook-form/react-hook-form? I am hoping RHF can get more popular, while RHFInput is a support package :) sorry I didn't make it clear 👍

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

what do you mean onmount validation?

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

guess we can close this issue, we can continue the conversation in here anyhow

from input.

bluebill1049 avatar bluebill1049 commented on July 19, 2024

by the way if you have other questions, feel free to join our spectrum channel. sometimes even the community can answer your questions :) (and i am in there too).

from input.

matiushariman avatar matiushariman commented on July 19, 2024

for sure @bluebill1049 , I'm already inside the channel actually.

Looking forward to discussing more & potentially helping you guys out. Thanks again :)

from input.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.