question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Form is not considered "dirty" when removing the last item in a nested array.

See original GitHub issue

Describe 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:

  1. Go to Codesandbox lint
  2. The first demo is a non-nested field array. Removing updates state.
  3. 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jonhaddowcommented, Jun 9, 2020

Nice one! Thanks for the quick response and fix 👍

0reactions
bluebill1049commented, Jun 9, 2020

Thanks for reporting those issues too. appreciated.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found