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

fix(useField): Fix no re-render on initialValue change #1034

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jspannu919
Copy link

Currently useField doesn't retriggers properly if the initialValue is changed (Added test scenario).
Added explicit check for initial value change to prevent deepEqual overheads.

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit fe2fb36:

Sandbox Source
final-form/react-final-form Configuration
final-form/react-final-form Configuration
final-form/react-final-form Configuration
final-form/react-final-form Configuration
final-form/react-final-form Configuration

@bslipek
Copy link

bslipek commented May 25, 2023

IMO this is fine, you should not listen for initialValues after form initialization. Why you need this?

@jspannu919
Copy link
Author

@bslipek In data driven forms (Ref: https://github.com/data-driven-forms/react-forms ) for conditionally hiding the fields, the fields are wrapped with a Field component so that they get re-rendered when the value in any of the parent attribute change(Ref: https://github.com/data-driven-forms/react-forms/blob/84c4cb8861d689cb87ba68100fe7d3acfd667655/packages/react-form-renderer/src/form-renderer/render-form.js#L47). So, due to the above issue the conditional visibility doesn't works if we reverse the order of the fields(Ref: https://stackblitz.com/edit/1dkk8s-rd1ejn?file=schema.js).

@bslipek
Copy link

bslipek commented May 26, 2023

I got your point. But still think that this is final-form problem. But I am just a observer here :)

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.

None yet

2 participants