Skip to content

useFieldArray only works with deconstruct #3768

Answered by logaretm
expliArturSmolen asked this question in Q&A
Discussion options

You must be logged in to vote

This is a setup caveat, not a vee-validate issue. Because setup doesn't unwrap refs recursively, so you either need to do that yourself like:

<!-- fields is a ref, so you need to unwrap it -->
<div v-for="(field, idx) in fieldArray.fields.value" >

or You can also wrap useFieldArray with reactive which is mentioned by Vue docs. Note that you cannot destruct it if you use this approach.

import {  useFieldArray } from "vee-validate";
import { reactive } from 'vue';

const fieldArray = reactive(useFieldArray('users'));

I will add a quick note to the docs about this.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by expliArturSmolen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants