Cheatsheet collection for go, rust, python, shell and javascript.

How to reset form after submit action in remix?

Here's what you need to do if you need to clear form after submitting in remix.

  • Setup the hook.
let transition = useTransition();
let isAdding = transition.state == "submitting";
let formRef = useRef<HTMLFormElement>(null);

useEffect(() => {
    if (!isAdding) {
}, [isAdding]);
  • Don't forget to add the ref to form.
return (
        <Form ref={formRef}>

See other cheatsheet's here