2

I have an array: const arr = []

I then have a computed property:

const filtered_arr = computed(() => {
 //...
}

I then have another computed property: filtered_arr2 where I want to call some() method on the first filtered_arr. But getting errors since filtered_arr is not an actual array.

const filtered_arr2 = computed(() => {
  filtered_arr.some((e)=>{}) // <- error
}

UPDATED:

Getting several errors :

  1. some is not a function

  2. Container is not set or can not be properly recognized. Use container() method to set it

I think my whole approach is buggy...

0

1 Answer 1

1

From the API documentation...

computed()#

Takes a getter function and returns a readonly reactive ref object

and

ref()#

Takes an inner value and returns a reactive and mutable ref object, which has a single property .value that points to the inner value

So with that in mind, you'll need to use the .value property within your setup

const filtered_arr = computed(() => {
  // return some array
});

const filtered_arr2 = computed(() => {
  const isPresent = filtered_arr.value.some(...);
  // return some other value
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.