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

Array items not being regenerated #11

Closed
soup-in-boots opened this issue Nov 7, 2020 · 1 comment
Closed

Array items not being regenerated #11

soup-in-boots opened this issue Nov 7, 2020 · 1 comment
Assignees

Comments

@soup-in-boots
Copy link
Collaborator

When using the form generator hook with arrays, items are not updated if the form changes. This appears to be an issue with the useArrayItems hook.

@soup-in-boots
Copy link
Collaborator Author

useArrayItems' useEffect to initialize the forms was at fault. It would only run once on initialization, and any forms created in that run would essentially be static. Adding new items would create new, updated forms, but items were essentially one render behind.

Triggering the effect on every value update (the right thing) was blasting away all of the forms, causing inputs to be re-rendered and form input focus to be lost. Instead of creating all new items, the patch now iterates over the existing items, updating them if they exist and creating them if they don't.

Fixed in v1.3.2

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

No branches or pull requests

1 participant