question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dispatching submit after initialize yields wrong form values

See original GitHub issue

Type

Probably a bug.

Process

  1. Set onSubmit to handleSubmit(data => ...).
  2. Dispatch an initialize(FORM_NAME, {}) action to clear initialValues.
  3. Dispatch a reset(FORM_NAME) action to revert to the previously initialized values.
  4. Dispatch a submit(FORM_NAME) action to submit empty values.

Current behavior

  1. Parameter data is a string and equals the FORM_NAME value.

Expected behavior

  1. Parameter data is an empty object.

Environment

redux-form@6.4.3

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
duhseekohcommented, Aug 14, 2017

This is happening to me on 7.0.3. My scenario is not in one synchronous block.

  1. User taps submit button
  2. This gets triggered
onClick={props.handleSubmit(vals => {
                  // onSubmit is defined in a wrapper component
                  props.onSubmit(vals, CONTENT_FORM_ACTIONS.PUBLISH);
                })}
  1. Redux action uses the values to submit to api
  2. on return of that api call, an initialize is called
dispatch(initialize('content', {
  id: savedItem.id,
  ...vals
}, false);
  1. At this point, the ‘content’ redux-form has the correct state. initial is updated and so is values.
  2. User types something in the form fields
  3. User presses submit again. initial is correct and values are correct, BUT, the values sent to the handleSubmit method are still the initial. They never get set to values. The reducer is correctly updating, but handleSubmit does not. It’s also worth mentioning that the dirty flag is correctly reset from the initialize, but any field modifications after that do not set the dirty flag to true.

It’s like the react component is partially disconnected from redux-form after the initialize. By not doing an initialize, everything stays in sync (but i dont get the dirty property reset, which is ultimately what im going for)

0reactions
lock[bot]commented, Dec 26, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to keep redux-form submission errors after switching from ...
When I receive the field errors from the server, I put them on redux-store using "stopSubmit" action creator (tried using setSubmitFailed too, ...
Read more >
submit -> submitSuccess -> reinitialize -> form.pristine == true ...
dispatch (initialize(props.form.name, props.form.values) }. After the form ... I expect pristine to become false after form data is changed.
Read more >
What is "Input dispatching timed out" and how to solve it
It means, the main thread which stacktrace you're showing here is stuck, and it didn't process the event that was being send to...
Read more >
Handling Forms in Svelte - This Dot Labs
Currently, our form does nothing. We need to handle the submit event on the form. To do that, we must add a handler....
Read more >
reduxForm(config:Object)
a function that takes all the form values, the dispatch function, the props given to your component and the current blurred field, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found