How to avoid Components running setup() again on subsequent page loads

The home page of our app is a scrolling feed of content called Home.vue. When you tap on one, it takes you to a page for that content, Blog.vue. In Blog.vue’s setup() function, we make an API request to load the content data.

If you back out of that page back to Home.vue, then click on a link to the preferences page, Options.vue, it seems to run the setup() function Blog.vue again based on console logs.

What can I do to avoid this? It’s not a major issue, the app works fine, but it’s giving javascript errors in some cases, and I imagine that’s causing the app’s memory usage to increase as the user visits more pages

Hey there! Try updating to Ionic Vue 5.8.5. There was a bug that we just fixed that should resolve this.

npm install @ionic/vue@5.8.5 @ionic/vue-router@5.8.5
1 Like