Hacker News new | past | comments | ask | show | jobs | submit login

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.






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.


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!


wow so cool~ https://picnicss.com/ love it. stared the project. <3



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: