Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
vue/composition-api ref only 1 level deep

I know that with ref you have an object/array/primitive reactive, and if it was an object or array it is made deeply reactive.

And with shallowRef you can have only the variable itself reactive but is not made deeply reactive.

In my case I have an array of JSONs where I would like to make reactive the array and the first deep level, because the only actions I am doing is push/slice new items or change the array variable.

So I could use ref([]), but this will make the full JSON reactive which I don't need. And I can not use shallowRef(), because this will work when changing the full json. But won't work with the push/slice actions.

Is there something I am missing? How can I do this approach?

const arr = shallowRef([]);

arr.value.push(JSON); // Not reactive
arr.value.slice(index, 1); //Not reactive
arr.value = [JSON_1, JSON_2]; //reactive
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda