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

Linking from page with form to another page with form destroys the redux-form #1613

Closed
nik-lampe opened this issue Mar 6, 2018 · 4 comments
Assignees
Labels

Comments

@nik-lampe
Copy link
Contributor

nik-lampe commented Mar 6, 2018

update

All the debugging lead me to this:
redux-form/redux-form#3435

It is a problem with React 16 and the way redux-form handles the initializing and destroying of the forms in their components lifecycle

What you were expecting:
I am linking from an edit page with a form to a create page with a form passing some values by the query parameters. I am trying to fill these parameters as default values to the form. That's how I found this.

What happened instead:
It looks like the destroyOnUnmount function of redux-form destroys the form after it has been initalized.

Maybe this comes somewhere between redux-form 6.6.3 which is used in aor 1.2.1 and redux-form 7.0.4

Related code:
See an example application here:
https://github.com/nik-lampe/admin-on-rest-form-destruction

I had problems recreating this bug in the older version of admin-on-rest which is included in the CodeSandbox you're refering to: https://codesandbox.io/s/ElxGNxBY0

It seems to work with admin-on-rest 1.2.1. I have made a branch in the repo for this.

But updating the dependencies in the CodeSandbox seem to break the code, that's why I just created the sample application.

Steps to reproduce:

  1. Click on comments list.
  2. Click an create.
  3. See the initial value for the body.

Then:

  1. Click on posts list.
  2. Edit any Post.
  3. Click on "Add Comment" in the action bar.
  4. The body value should have a default value 'Test Body' but it doesnt. (I am not actually using any of the query parameters, I made this link just to show me use case for why I built it)
  5. Debugging the redux store shows the destruction of the record-form

1.4.0:
admin-on-rest 1.4.0

1.2.1:
admin-on-rest 1.2.1

Environment

  • Admin-on-rest version: 1.5.0
  • Last version that did not exhibit the issue (if applicable):
@nik-lampe
Copy link
Contributor Author

As I am using a customized version of admin-on-rest anyway I hacked together a temporary fix which is mentioned here redux-form/redux-form#3435 (comment)

This is not a fix, just a very hacky workaround

@jpetitcolas
Copy link
Contributor

We just found a way to fix it. We are working on it tomorrow. Should be ready in next release.

@jpetitcolas jpetitcolas self-assigned this Mar 7, 2018
@fzaninotto fzaninotto added the bug label Mar 7, 2018
@fzaninotto
Copy link
Member

It's fixed for the filter form in https://github.com/marmelab/admin-on-rest/pull/1616/files#diff-0c7e48ec3f03db5532bb24babd4872b8R184. We need to fix it in the create and edit forms.

@fzaninotto
Copy link
Member

Fixed by #1618

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

No branches or pull requests

3 participants