mobx-react-form icon indicating copy to clipboard operation
mobx-react-form copied to clipboard

How to set form submit disabled while I fetching async data for select fields?

Open kapilpipaliya opened this issue 6 years ago • 4 comments

kapilpipaliya avatar Jul 01 '18 10:07 kapilpipaliya

I'd either use a separate mobx store, or use the extra state property added in #220. In your onSubmit handler, you can check form.state.extra.isLoading and abort if necessary. In addition, you can set your Submit button to a disabled state if that prop is true

pdfowler avatar Jul 28 '18 02:07 pdfowler

Thanks. How to abort the form submit on onSubmit handler?

kapilpipaliya avatar Jul 31 '18 04:07 kapilpipaliya

I set submit button to be disabled when form.state.extra.isLoading is true. but, If i set form.state.extra.isLoading to true in some function start and false at the end of the same function, the submit button is not re-rendering its state.

kapilpipaliya avatar Jul 31 '18 04:07 kapilpipaliya

I’d confirm that extras.isLoading is observable and that your component can respond to it. As for stopping onSubmit, typically I’d set valid = false, but there may be a cleaner way (on mobile atm so I can’t dig thru the docs)

pdfowler avatar Jul 31 '18 16:07 pdfowler