wsmd/react-use-form-state

Auto-saving forms

oyeanuj opened this issue · 1 comments

Hi @wsmd, thanks for creating this useful library!

Quick question - I was wondering what is the best usage pattern recommended for autosaving forms? Do you think we should use onChange at the form level, parse the field that was updated and submit the results? Or use onChange at the field level? Or do you think the library can support submitOnChange as a first class option?

wsmd commented

Hi @oyeanuj,

I was wondering what is the best usage pattern recommended for autosaving forms? Do you think we should use onChange at the form level, parse the field that was updated and submit the results?

The library attempts to provide a great deal of flexibility, which means it's really up to the developer to handle various cases depending on the context. I think your auto-saving use case is a good fit for the form-level onChange. From there, you handle the form state object accordingly.

do you think the library can support submitOnChange as a first class option?

The library does not currently provide any submission functionality (since the main goal of this library is to make it easier to handle the form state itself related to inputs, not the actual form behavior). That said, I'm open to ideas and suggestions! Perhaps you could elaborate more on the submitOnChange suggestion to help better understand the problem it tries to solve.

I'd happily reopen on the issue if this does not answer your question. Let me know if you have any further questions!