#transition.submission not pending when dynamically submit form with submitRequest()

1 messages · Page 1 of 1 (latest)

rigid pebble
#

I'm building an autosave feature to my form built with remix Form. I added pending states by checking transition.submission from useTransition() and it worked like the doc examples.

However, if I triggered the submission dynamically, via requestSubmit formRef?.current?.requestSubmit(document?.getElementById("submitButton")), everything works... except the transition won't show a pending submission.

I could solve this by adding setting an extra useState for the autosave, but that's redundant code I'd like to avoid. Is there a better way I could autosave that would hook into remix lifecycle correctly?

note formRef.current.submit() doesn't work, because it ignores onSubmit and doesn't carry any submit button values with it.

#

transition.submission not pending when dynamically submit form with submitRequest()

remote silo
#

This does a full document request, not a JS based one. You should be looking at the useSubmit() hook instead of using the HTMLForm element directly.