-
-
Notifications
You must be signed in to change notification settings - Fork 481
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 a form programmatically #46
Comments
@erikras I'm trying to reset the form after resolving promise and this is not working. I am getting cannot read 'then' of undefined. The form submits just fine, just will not wait to reset. Code:
export default CreditDebitForm; |
See #21 (comment) and #21 (comment). |
I checked those out. I am on the latest version. |
Hmm... You do see it working in the sandbox, right? I wonder what is different about your setup? Your code looks just fine. |
@erikras OK. When you submitted the change you said to upgrade to 1.1.0. I did that, once I upgraded to 1.3.0 for f-f and 1.2.0 for r-f-f it started working. Sorry, that was frustrating. We are all good now with the same code. Thanks for your hard work!! |
@dbertella You can also call |
Great sorry I didn't see that, I probably looked into the wrong issues instead, I have just a problem, I'm using redux saga and the form submission is just a synchronous action, so I don't think it will work unfortunately @erikras what would be great here is a flag re-initialize on the |
@dbertella Let me restate your request to make sure I understand. You want: props.reinitialized === false // form might have been initialized, but has never been RE-initialized
props.reinitialized === true // form has had `reset()` or `initialized()` called on it at least once ? |
My problem is that I need to reset the form from outside the render prop, something that I could do with an action creator in redux form for example. What I'm doing as a work around is: according to a custom flag I'm setting the initialValues causing the form to re-render to the empty state but it works just the first time. |
@dbertella |
Sweet I like the the dead drop concept but I'm not sure about how to
implement the reset, I need to try it :-). Anyway the closure or a hidden
reset button triggered can help I think! Thank you very much for all the
effort!
|
Clojure did the job, I tried the event first but it didn't work with reset, I guess it's not handled via a custom event, I was thinking at something like this Anyway here is my code, it feels a little hacky but it does the job!
|
I think I'm going with this option as well. |
@dbertella @davidhenley you guys can use this approach as well redux-saga/redux-saga#161 (comment) |
@dbertella Thank you so much |
Anyone react hooks way? |
Have a similar question as @rendomnet. I'm using recompose. Any advice? |
Are you submitting a bug report or a feature request?
Feature request
Other information
I might missing something, but what is the correct approach to reset a form after successful submission? Without having a reset button of course.
I couldn't see anything about this in the documentation.
I can inject new empty
initialValues
from props maybe, but it doesn't seem very clean.The text was updated successfully, but these errors were encountered: