fix: persist async data across tab navigation#963
Conversation
The imports tab (and other tabs) would show empty after navigation because Nuxt's purgeCachedData cleared the cached data on unmount. The default getCachedData only checks nuxtApp.static.data (empty in SPA mode), not payload.data where the actual fetch result is stored. By providing a custom getCachedData that reads from payload.data: 1. Data persists across unmount/remount cycles 2. Prevents clearNuxtDataByKey from running (line 459 of asyncData.js) 3. Pages render instantly with previous data instead of showing blank This fixes the empty imports/components/pages tabs on navigation back. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Deploying nuxt-devtools with
|
| Latest commit: |
ba62838
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f71b992f.nuxt-devtools.pages.dev |
| Branch Preview URL: | https://antfu-fix-imports-tab-empty.nuxt-devtools.pages.dev |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change modifies the Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The imports tab (and other tabs) would show empty after navigating away and back because Nuxt's
purgeCachedDatacleared the cached data on unmount. When remounting, the defaultgetCachedDataonly checksnuxtApp.static.data(empty in SPA mode), notpayload.datawhere the actual fetch result is stored.Solution
Provide a custom
getCachedDatathat reads frompayload.data[key]. This both:clearNuxtDataByKeyfrom running when the last consumer unmounts (line 459 of asyncData.js)Testing
The imports, components, and pages tabs should now persist data correctly across navigation without showing empty states.
🤖 Generated with Claude Code