react-mailchimp-subscribe
react-mailchimp-subscribe copied to clipboard
Reset form
There is some way to reset the form after return success?
To future travelers, I was able to reset the form by changing the key
on the MailchimpSubscribe
component. Beware, this will force that component to mount/remount--which is probably what you want but may have side effects depending on how you wire it up!
To future travelers, I was able to reset the form by changing the
key
on theMailchimpSubscribe
component. Beware, this will force that component to mount/remount--which is probably what you want but may have side effects depending on how you wire it up!
A working example of this would be really helpful.
@JayBox325 I no longer have access to that codebase, but literally as simple as the below. :) Not the most elegant thing, but just exploiting the react-ism that changing a key forces a component to re-render (and wipe its state)!
<MailchimpSubscribe key={someValueYouChangeWhenYouWantToReset} />
or, on a parent:
<MyModalThatContainsMailchimpSubscribe key={someValueYouChangeWhenYouWantToReset} />