createEntry maybe not need passed value #3770
Replies: 1 comment 3 replies
-
I always use an exhaustive approach when it comes to types and handling. Since For example, the user passes a field entry to a function, then removes it from the array. Then sets/gets its value from the passed object, then it would be
Do you have evidence of this? for example, a memory profile showing that it causes a memory leak? If it is never accessed then it shouldn't be a problem. What issue are you solving here? did you encounter a problem with |
Beta Was this translation helpful? Give feedback.
-
Maybe we not need pass value for
createEntry()
.In
useFieldArray()
, function thatcreateEntry()
help us create an entry that reference specific path field value withcomputed
.vee-validate/packages/vee-validate/src/useFieldArray.ts
Lines 58 to 74 in 800641f
vee-validate/packages/vee-validate/src/useFieldArray.ts
Lines 91 to 105 in 800641f
Currently, it will return we passed value when
key
is not exist in fields, but maybe this will never happen.As we know
computed
is evaluated lazily on access, that means it is not computed immediately, until it is accessed.So, when it is accessed, this entry already exist in
filed
, theidx
is never equal to-1
, and we don't need to pass value forcreateEntry()
On the other hand, if thevalue
is never used, it may still be referenced and let memory leak, so we need to avoid to use thevalue
in computed (in my opinion)Beta Was this translation helpful? Give feedback.
All reactions