Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

67
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!