Skip to content

Instantly share code, notes, and snippets.

@wking-io
Created December 8, 2022 14:33
Show Gist options
  • Save wking-io/60dbc3b6871b32d928abb42af392e2a5 to your computer and use it in GitHub Desktop.
Save wking-io/60dbc3b6871b32d928abb42af392e2a5 to your computer and use it in GitHub Desktop.
remix-submit-on-headlessui-switch-change
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