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

[BUG] useFieldArray options dissapear after routing away and back to edit page #5894

Closed
doender opened this issue Apr 25, 2024 · 2 comments · Fixed by #5903
Closed

[BUG] useFieldArray options dissapear after routing away and back to edit page #5894

doender opened this issue Apr 25, 2024 · 2 comments · Fixed by #5903
Assignees
Labels
bug Something isn't working
Milestone

Comments

@doender
Copy link

doender commented Apr 25, 2024

Describe the bug

I'm running into issues using useFieldArray. This example here https://github.com/refinedev/refine/tree/master/examples/blog-react-hook-dynamic-form has the same bug: when you go from the list to the edit page of a record you can see the skills in the form, but when you then route to the list page and back to the record edit page the skills have disappeared

Steps To Reproduce

  1. Checkout the example: https://github.com/refinedev/refine/tree/master/examples/blog-react-hook-dynamic-form
  2. Click on the first record edit button: skills are shown
  3. Go back to the list page
  4. Click on the first record edit button again: skills are gone

Expected behavior

The fields are shown

Packages

See the example

Additional Context

No response

@doender doender added the bug Something isn't working label Apr 25, 2024
@aliemir aliemir self-assigned this Apr 30, 2024
@aliemir
Copy link
Member

aliemir commented Apr 30, 2024

Hey @doender, just opened up a PR #5903 to fix this issue in our blog-react-hook-dynamic-form.

We're using setValue from useForm of react-hook-form internally in our useForm of @refinedev/react-hook-form to set values per registered field of a record. This does not trigger a re-render and results in outdated display of the array field. Check out the related issue from react-hook-form here react-hook-form/react-hook-form#1564

The advised workaround was to use useWatch or watch to properly rendering the field. In #5903 I did the same, you can check it out to help you resolve issue on your project! 🚀

@aliemir aliemir added this to the May Release milestone Apr 30, 2024
@doender
Copy link
Author

doender commented Apr 30, 2024

Yes, this workaround works, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants