News for hackers. Stuff that matters.
Re:Show HN: React Hook Form – Simple Form Validation by CGamesPlay on Wednesday October 09, 2019 @05:50AM (#21201604)
This looks really good. But is there a non-hook version for use in class components? I'm imagining it might look like this:

    class MyForm extends React.Component {
      formState = new ReduxHookForm();

      render() {
        const { register, handleSubmit } = this.formState;
        return (
          <form onSubmit={handleSubmit(this.handleSubmit)}>
            <input name="firstName" ref={register} />
            <select name="gender" ref={register}>
              <option value="male">male</option>
              <option value="female">female</option>
            </select>
            <input type="submit" />
          </form>
        );
      }

      handleSubmit(data) {
        console.log(data);
      }
    }
Re:Show HN: React Hook Form – Simple Form Validation by franciscop on Wednesday October 09, 2019 @07:53AM (#21202273)
I have a pure-javascript library that works like that, "forn". No hooks or any local state needed:

https://www.npmjs.com/package/forn

Re:Show HN: React Hook Form – Simple Form Validation by bluebill1049 on Wednesday October 09, 2019 @06:00AM (#21201652)
I haven't got a plan to look into class component just yet, but will do in the near future.
Re:Show HN: React Hook Form – Simple Form Validation by ozgrozer on Wednesday October 09, 2019 @02:21PM (#21206218)
I made this one last year. It can be used with class components too.

https://github.com/ozgrozer/rfv

Re:Show HN: React Hook Form – Simple Form Validation by bluebill1049 on Wednesday October 09, 2019 @05:54AM (#21201622)
yea would be similar for class component :)
Re:Show HN: React Hook Form – Simple Form Validation by CGamesPlay on Wednesday October 09, 2019 @05:56AM (#21201630)
Sorry I don't understand. Last time I checked, hooks are not usable from class components. How can I use react-hook-form from a class component?
Re:Show HN: React Hook Form – Simple Form Validation by bluebill1049 on Wednesday October 09, 2019 @06:01AM (#21201657)
Sorry I meant once I made it work, and it will be the syntax