News for hackers. Stuff that matters.
Re:Show HN: React Hook Form – Simple Form Validation by franciscop on Wednesday October 09, 2019 @07:48AM (#21202245)
Hey author I like this! It's very close to what I use for simple forms, my library `forn`:

    import forn from 'forn';
    
    export default () => (
      <form onSubmit={forn(data => console.log(data))}>
        <input name="firstName" placeholder="First Name" />
        <input name="lastName" placeholder="Last Name" />
        <button>Send!</button>
      </form>
    );
Test it: https://codesandbox.io/s/agitated-johnson-3hv96

Why do you need the register though? Is the hook needed to hold the refs? Is it only for compatibility with React Native or are there other reasons? With forn I use `e.target`, which should not be available in RN.

Re:Show HN: React Hook Form – Simple Form Validation by bluebill1049 on Wednesday October 09, 2019 @07:58AM (#21202306)
hey, nice lib you got there :) When I was deciding the API, I did have the idea of just collecting form input automatically (similar to forn), but there are few reasons which lead to the final decision:

1. Support React controlled component. eg some of the popular component libs, they are wrapped input inside their component and it's hard to predict which to include during the form submit.

2. React Native <3

3. Attach validation rules, messages and async validation on the individual field level.

Re:Show HN: React Hook Form – Simple Form Validation by franciscop on Wednesday October 09, 2019 @08:11AM (#21202387)
Ha thanks! You described perfectly the limitations of `forn` and why I only use it for simpler forms. React Native is a big pain from tine to time though I barely use it. I also made https://picnicss.com/ so I'm used to use the native form elements underneath and the rest being just a pretty wrap. But yeah, as soon as I add a 3rd party form lib all goes to hell and `forn` doesn't work well anymore.

I'll try it next time I have to deal with React Native!

Re:Show HN: React Hook Form – Simple Form Validation by bluebill1049 on Wednesday October 09, 2019 @08:14AM (#21202404)
wow so cool~ https://picnicss.com/ love it. stared the project. <3