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

Add possibility to change function passed to handleSubmit #4684

Merged

Conversation

ideffix
Copy link
Contributor

@ideffix ideffix commented Jul 16, 2020

Closes #4682

When submiting form remotely by dispatching submit action and during Form lifetime and method provided to handleSubmit has changed - it isn't fired - only first function provided to Form is fired. After invastigation I've noticed that for remote submitting submit function from createReduxForm.js calls method innerOnSubmit() and it is set with following function: registerInnerOnSubmit: innerOnSubmit => (this.innerOnSubmit = innerOnSubmit).
In Form.js I can see that it only register method when component will mount this.props._reduxForm.registerInnerOnSubmit(this.props.onSubmit) so even if you change method provided to handleSubmit during Form life, it wont be fired onSubmit.
My fix adds possibility to change that method during Form life.

@ideffix
Copy link
Contributor Author

ideffix commented Jul 21, 2020

Hi @iamandrewluca, can we do something with it?

@iamandrewluca
Copy link
Member

iamandrewluca commented Jul 22, 2020

We don't want to add any legacy things, this will make development of library even harder if we want to move on with next versions of react.

Note:

These methods are considered legacy and you should avoid them in new code:

UNSAFE_componentWillUpdate()
UNSAFE_componentWillReceiveProps()
https://reactjs.org/docs/react-component.html

@ideffix
Copy link
Contributor Author

ideffix commented Jul 23, 2020

@iamandrewluca I've changed unsafe methods of this component

src/Form.js Outdated Show resolved Hide resolved
@iamandrewluca iamandrewluca merged commit 71802db into redux-form:master Jul 23, 2020
@iamandrewluca
Copy link
Member

iamandrewluca commented Jul 23, 2020

Thankss @ideffix, I'll find some time to make a new release.

@ideffix
Copy link
Contributor Author

ideffix commented Nov 17, 2020

Hi @iamandrewluca, I know its been a while since this PR was merged to master, but can we have a realease version with it? I kinda need it now :D

@erikras
Copy link
Member

erikras commented Nov 17, 2020

Published in v8.3.7.

@iamandrewluca
Copy link
Member

@ideffix FYI

@ideffix
Copy link
Contributor Author

ideffix commented Nov 17, 2020

Gr8, thanks guys! 🥇

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

Successfully merging this pull request may close these issues.

handleSubmit fires cached version when form is submited by dispatch
3 participants