Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

unregister react hook form

import React, { useEffect } from "react";
import { useForm } from "react-hook-form";

export default function App() {
  const { register, handleSubmit, unregister } = useForm();
  
  React.useEffect(() => {
    register("lastName");
  }, [register])

  return (
    <form>
      <button type="button" onClick={() => unregister("lastName")}>unregister</button>
      <input type="submit" />
    </form>
  );
}
Source by react-hook-form.com #
 
PREVIOUS NEXT
Tagged: #unregister #react #hook #form
ADD COMMENT
Topic
Name
2+2 =