• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

143
Vistas
How can I get stored value in Vue 3?

I want to get the value of my stored user from my store

but when I tried on onMounted function

onMounted(async () => {
       console.log('user', store.state.user)  //here i can see the values
        const info = computed(() => {
        return store.state.user
      })
      console.log('info', info)

it does not give the information, I am getting info.name undefined

what happening here?

almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

info is a ref, it cannot have info.name. It's a mistake to use computed inside mounted hook, it should be directly inside setup:

const info = computed(() => store.state.user)

onMounted(async () => {
      console.log('info', info.value)
});

store.state.user value is not guaranteed to be up-to-date at the time when it's accessed. In case it changes during the component's lifespan, it needs to be accessed inside a watcher or another computed property.

almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda