Form is not considered "dirty" when removing the last item in a nested array.
See original GitHub issueDescribe the bug
When using a nested array (prop.nestedProp
), the form state is not updated when the last item is removed.
To Reproduce Steps to reproduce the behavior:
- Go to Codesandbox lint
- The first demo is a non-nested field array. Removing updates state.
- The second demo is a nested field array. Removing doesn’t updates state.
Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-usefieldarray-f0uv2?file=/src/index.js
Expected behavior I expect form state to be updated when using a field array for a nested property.
Desktop (please complete the following information):
- OS: Windows
- Browser: Chrome
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to remove the last index in nested array - Stack Overflow
I am assuming that you don't want to alter the original array variable and you want to remove only the last index, no...
Read more >10 Most Common Mistakes That PHP Developers Make - Toptal
Common Mistake #1: Leaving dangling array references after foreach loops. Not sure how to use ... The last value on the last line...
Read more >array - Manual - PHP
Having a trailing comma after the last defined array entry, while unusual, ... "Quick and dirty" class to get an offset of multidimensional...
Read more >use-form - Mantine
// An optional index may be provided to specify the position in a nested field. // If the index is passed where an...
Read more >How to Deep Clone an Array in JavaScript - DEV Community
If you want a true copy of nested arrays, you'll need a deep clone. ... So the solution is to copy over the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nice one! Thanks for the quick response and fix 👍
Thanks for reporting those issues too. appreciated.