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.

Value isn't passed to Controller after using useFieldArray's append

See original GitHub issue

Describe the bug I’m using useFieldArray and mapping that array to show multiple TextFields. But when I called useFieldArray’s append function with a new value, that new value is added to the form but it isn’t passed as value to the new input. I added some console logging to the codesandbox to show what I’m saying.

To Reproduce Steps to reproduce the behavior:

  1. Go to sandbox example linked below
  2. Click on the append button
  3. The new TextField should show the new value, but it isn’t showing.

Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-usefieldarray-forked-eefkf?file=/src/index.js

Expected behavior I expected the new TextField to receive the new value as value, but it isn’t receiving it.

Desktop:

  • OS: MacOS Big Sur 11.2.3 (20D91)
  • Browser: Chrome
  • Version: 89.0.4389.90 (Official Build) (x86_64)

Additional context I also noted something else that might be related with this. https://codesandbox.io/s/simple-mmtbq?file=/src/index.js When I rerender a component (with a state update for example) that uses useFieldArray, form.getValues() and form.watch() show an empty array. fields is still looking fine, but I find it weird that the previous values are gone from the form. Is that ok or am I missing something?

I’m using v7.1.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
marianozicavocommented, Apr 18, 2021

You’re right! My bad. thanks

0reactions
bluebill1049commented, Apr 18, 2021

You’re right! My bad. thanks

all good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useFieldArray using Controller · Discussion #1796 - GitHub
I saw an example for Field Arrays using Controller but I thought it's not what I am looking for because it logged same...
Read more >
useFieldArray with Material UI Select doesn't work
Since you are using controlled components, we need to make sure we set the default value of selectedVal to the default value passed...
Read more >
useFieldArray - Simple React forms validation
Append input/inputs to the end of your fields and focus. The input value will be registered during this action. Important: append data is...
Read more >
React Hook Form V7 with Material UI and Typescript Tutorial
In this video, I will help in understanding useFieldArray to create dynamic lists or tables.Link to starter project to follow ...
Read more >
API Documentation - Simple React forms validation
React Native: Custom register or using Controller ... Note: When you unregister an input, its value will no longer be included in 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