react-hook-form

📋 React Hooks for form state management and validation (Web + React Native)

MIT License

Downloads
25.6M
Stars
39.4K
Committers
318
react-hook-form - Version 3.17.4

Published by bluebill1049 over 5 years ago

react-hook-form - Version 3.17.3

Published by bluebill1049 over 5 years ago

  • fix a bug where errors are not cleear after succesfful submit
react-hook-form - Version 3.17.2

Published by bluebill1049 over 5 years ago

  • improve typescript support
react-hook-form - Version 3.17.0

Published by bluebill1049 over 5 years ago

  • setValue support validation as thrid argument:
    setValue('name', 'value', true)
  • triggerValidation with array of fields should only trigger one re-render when execute (batch update)
  • setValue remove api shouldRender
react-hook-form - Version 3.16.2

Published by bluebill1049 over 5 years ago

react-hook-form - Version 3.16.0

Published by bluebill1049 over 5 years ago

  • remove forceValidation from 'triggerValidation` to differentiate from validation mode, please refer to formState.
react-hook-form - Version 3.15.1

Published by bluebill1049 over 5 years ago

  • support triggerValidation with multiple names
react-hook-form - Version 3.14.0

Published by bluebill1049 over 5 years ago

  • add clearError(name: string) to clear an error which you can do setError(name: string)
react-hook-form - Version 3.13.3

Published by bluebill1049 over 5 years ago

react-hook-form - Version 3.13.2

Published by bluebill1049 over 5 years ago

react-hook-form - Version 3.13.1

Published by bluebill1049 over 5 years ago

  • patch a bug on native validation
react-hook-form - Version 3.13.0

Published by bluebill1049 over 5 years ago

nativeValidation Code example:

import React from "react";
import ReactDOM from "react-dom";
import useForm from "./src";

import "./styles.css";

function App() {
  const { register, handleSubmit } = useForm({
    nativeValidation: true
  });
  const onSubmit = async data => {
    alert(JSON.stringify(data));
  };

  return (
    <form onSubmit={e => e.preventDefault()}>
      <label>First name</label>
      <input
        name="firstName"
        ref={register({ required: "Please enter your first name." })}
      />
      <label>Last name</label>
      <input
        name="lastName"
        ref={register({ required: "Please enter your last name." })}
      />
      <input type="submit" onClick={handleSubmit(onSubmit)} />
    </form>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
react-hook-form - Version 3.12.0

Published by bluebill1049 over 5 years ago

This new feature allows your deep nested component to easily invoke hook methods.

Code Example below:

import React from "react";
import ReactDOM from "react-dom";
import useForm, { FormContext } from "./src";
import Test from "./Test";

import "./styles.css";

function App() {
  const methods = useForm();
  const { register, handleSubmit } = methods;
  return (
    <FormContext {...methods}>
      <form onSubmit={handleSubmit(data => console.log(data))}>
        <h1>Hello CodeSandbox</h1>
        <input name="test" ref={register({ required: true })} />
        <h2>Start editing to see some magic happen!</h2>
        <Test />
        <button>test</button>
      </form>
    </FormContext>
  );
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
import * as React from "react";
import useForm, { useFormContext } from "./src";

export default function Test() {
  const { register } = useFormContext();
  return (
    <div>
      <input name="bill" ref={register} />
    </div>
  );
}
react-hook-form - Version 3.11.9

Published by bluebill1049 over 5 years ago

react-hook-form - Version 3.11.8

Published by bluebill1049 over 5 years ago

react-hook-form - Version 3.11.7

Published by bluebill1049 over 5 years ago

  • fix type error for setError, the second argument should be optional
react-hook-form - Version 3.11.6

Published by bluebill1049 over 5 years ago

  • include isValid in the formState
react-hook-form - Version 3.11.5

Published by bluebill1049 over 5 years ago

  • fix a bug with setError setError() from submit handler not working #88
react-hook-form - Version 3.11.4

Published by bluebill1049 over 5 years ago

react-hook-form - Version 3.11.3

Published by bluebill1049 over 5 years ago

  • fix a bug with name check for object shape.