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

Submitting not getting reset after submit #487

Closed
michaltk opened this issue May 20, 2019 · 2 comments · Fixed by #495
Closed

Submitting not getting reset after submit #487

michaltk opened this issue May 20, 2019 · 2 comments · Fixed by #495

Comments

@michaltk
Copy link
Contributor

What is the current behavior?

When subscribed to submitting state, submitting never gets updated back to false even after submitting.
This seems to work fine in v4 and only is an issue in v5.

What is the expected behavior?

After submit, submitting state should be false again.

Sandbox Link

See Demo

What's your environment?

React Final Form - 5.1.0
Final Form - 4.13.0

michaltk added a commit to michaltk/react-final-form that referenced this issue May 26, 2019
fixes final-form#487

Previously, when it was checking in the subscribe func if state updated https://github.com/final-form/react-final-form/blob/4ca1ce7a7800c08b249219e14740ec2c1ed7e222/src/ReactFinalForm.js#L89 - the current state `state` - was always the initial state, bec of js closures.

So, the `submitting` got set to `true` bec that was diff than the initial state but when attempting to set back to false.. it was checking original state of `false` with current state of `false` and it was equal and therefore did not update and reset state.

Changed to add `state` to the `useEffect` deps so it will rerun the effect, causing it to create a new subscribe func with the updated state.
erikras pushed a commit that referenced this issue May 27, 2019
fixes #487

Previously, when it was checking in the subscribe func if state updated https://github.com/final-form/react-final-form/blob/4ca1ce7a7800c08b249219e14740ec2c1ed7e222/src/ReactFinalForm.js#L89 - the current state `state` - was always the initial state, bec of js closures.

So, the `submitting` got set to `true` bec that was diff than the initial state but when attempting to set back to false.. it was checking original state of `false` with current state of `false` and it was equal and therefore did not update and reset state.

Changed to add `state` to the `useEffect` deps so it will rerun the effect, causing it to create a new subscribe func with the updated state.
@erikras
Copy link
Member

erikras commented May 27, 2019

Published fix in v6.0.0.

@lock
Copy link

lock bot commented Jun 24, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants