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

73
Visualizações
Vue 3 map getters

I have slight problem with Vue 3. Problem is that, first time when I visit the page, all looks good, but second time, when getter is loaded again, it will prerender the page. Basically I can see first load, delete first load and change with new one, but as I know it should just update the array and not prerender the fore ached table.

So here is what I messed up:

This is how my store file looks like:

export const forum = {
  state: {
    forum: []
  },

  actions: {
    async GET_FORUMS(commit: any, payload: any ) {
      API.get('/forum')
        .then((response: any) => {
          commit.commit('forum', response.data.data)
        }).catch((e) => (
          notif.error(e.message)
        )
      )
    }
  },

  mutations: {
    async forum(state: any, forum:any) {
      state.forum = forum
    },
  },

  getters: {
    forums(state:any) {
      return state.forum;
    },
  }
}

And here is the setup method in vue file.

const store = useStore();
const isLoading = ref(true)

const forums = computed(() => {
  return store.getters.forums
})

onBeforeMount(async () => {
  if (isLoading.value) {
    await store.dispatch('GET_FORUMS')
    isLoading.value = false
  }
});

What have I messed up here?

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