MagicForm Hooks

useMagicForm

catch the submit event and send it to the useMagicFormProvider

import { useRef } from "atomico";
import { useMagicForm } from "@atomico/magic-form/hooks";

function component() {
  const ref = useRef();
  const [state, submit] = useMagicForm(ref);
  return (
    <host>
      <form ref={ref} action="addUser">
        <input type="text" name="name" />
        <input type="email" name="email" />
        <button>Add user</button>
      </form>
    </host>
  );
}

useMagicFormProvider

receives the submits from useMagicForm

Last updated

Was this helpful?