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.

Nested field arrays break data.slice

See original GitHub issue

Describe the bug data.slice is not a function when removing multiple sub-elements in nested field arrays.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/react-hook-form-defaultvalues-4o5iu
  2. Click on “Add element”
  3. Click on “add subelement” twice
  4. Click on “remove subelement” twice
  5. After the second “remove subelement” the app breaks with data.slice is not a function

Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-defaultvalues-4o5iu

Expected behavior Sub-elements should be removed without an error.

Additional context If I add another element before removing the second sub-element it works fine. It seems like after removing one nested field array the state is left in a bad state.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
bluebill1049commented, Mar 14, 2020

https://react-hook-form.com/api#useFieldArray Screen Shot 2020-03-15 at 9 24 45 am

it’s due to register not to get invoked inside map when using with FormContext.

1reaction
rnnyrkcommented, Mar 19, 2020

Thanks for this one, also missed it in the docs but this resolved the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can i split an array into a nested array by splitting each ...
Here I use functional in PHP to extract data $arrays = [ "Song 1 by ... Then you need split by $row =...
Read more >
How do I slice a nested array and how do I update a specific ...
Hi, I have the following data: { _id: "some_id", array1: [ { _id: ... and it will slice each array2 within the respective...
Read more >
Spark - How to slice an array and get a subset of elements
slice function takes the first argument as Column of type ArrayType following start of the array index and the number of elements to...
Read more >
Nested Arrays in JavaScript - ELATED.com
This tutorial explains how to nest arrays in JavaScript, ... In a nested array, the elements of one array are themselves arrays.
Read more >
Work with arrays | BigQuery - Google Cloud
Querying nested arrays. If a table contains an ARRAY of STRUCT s, you can flatten the ARRAY to query the fields of 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