Created
December 8, 2022 14:33
-
-
Save wking-io/60dbc3b6871b32d928abb42af392e2a5 to your computer and use it in GitHub Desktop.
remix-submit-on-headlessui-switch-change
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ExampleForm() { | |
const submit = useSubmit() | |
const formRef = useRef<HTMLFormElement>(null) | |
const submitOnChange = useCallback(() => { | |
if (formRef?.current) { | |
submit(formRef.current, { replace: true }) | |
}, [formRef, submit]) | |
return ( | |
<Form ref={formRef}> | |
<Switch onChange={submitOnChange}> | |
... | |
</Switch> | |
</Form> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment