Skip to content

Commit

Permalink
fix: vuex useStore in script setup crashes inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Sep 24, 2022
1 parent b06d7f1 commit d36329c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/shared-utils/src/util.ts
Expand Up @@ -240,6 +240,10 @@ function replacerForInternal (key) {
return `[native VNode <${val.tag}>]`
} else if (typeof HTMLElement !== 'undefined' && val instanceof HTMLElement) {
return encodeCache.cache(val, () => getCustomHTMLElementDetails(val))
} else if (val.constructor?.name === 'Store' && val._wrappedGetters) {
return `[object Store]`
} else if (val.currentRoute) {
return `[object Router]`
}
const customDetails = getCustomObjectDetails(val, proto)
if (customDetails != null) return customDetails
Expand Down
9 changes: 9 additions & 0 deletions packages/shell-dev-vue3/src/SetupScript.vue
@@ -1,6 +1,8 @@
<script setup>
import Child from './Child.vue'
import { ref, computed, reactive } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
const myObj = reactive({
foo: 'bar',
Expand All @@ -19,6 +21,13 @@ const state2 = reactive({
function onClick () {
count.value++
}
const throws = computed(() => { throw new Error('oops') })
const store = useStore()
const throwsWithVuex = computed(() => store.getters.throws)
const router = useRouter()
</script>

<template>
Expand Down
3 changes: 3 additions & 0 deletions packages/shell-dev-vue3/src/store.js
Expand Up @@ -9,6 +9,9 @@ const store = createStore({
},
getters: {
answer: (state) => state.answer,
throws: () => {
throw new Error('getter error')
},
},
mutations: {
increment (state) {
Expand Down

0 comments on commit d36329c

Please sign in to comment.