Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset form #66

Open
AndreVizosodaCruz opened this issue Jul 5, 2021 · 3 comments
Open

Reset form #66

AndreVizosodaCruz opened this issue Jul 5, 2021 · 3 comments

Comments

@AndreVizosodaCruz
Copy link

There is some way to reset the form after return success?

@bryantcodesart
Copy link

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!

@JayBox325
Copy link

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!

A working example of this would be really helpful.

@bryantcodesart
Copy link

bryantcodesart commented Jun 26, 2023

@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} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants