Skip to content

Commit

Permalink
try ref() instead of reactive()
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Jun 6, 2024
1 parent 334634c commit 538dcb4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/vue-full/renderer/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ function createApp(pageContext: PageContext) {
changePage: (pageContext: PageContext) => {
const data = pageContext.data ?? {}
assertDataIsObject(data)
Object.assign(dataReactive, data)
dataReactive.value = data
Object.assign(pageContextReactive, pageContext)
pageRef.value = markRaw(pageContext.Page)
}
})

const data = pageContext.data ?? {}
assertDataIsObject(data)
const dataReactive = reactive(data)
const dataReactive = ref(data)
const pageContextReactive = reactive(pageContext)
setPageContext(app, pageContextReactive)
setData(app, dataReactive)
Expand Down
6 changes: 3 additions & 3 deletions examples/vue-full/renderer/useData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ export { useData }
export { setData }

import { inject } from 'vue'
import type { App } from 'vue'
import type { App, Ref } from 'vue'

const key = Symbol()

/** https://vike.dev/useData */
function useData<Data>(): Data {
const data = inject(key)
const data = inject(key) as Ref
if (!data) throw new Error('setData() not called')
return data as any
return data.value as any
}

function setData(app: App, data: unknown): void {
Expand Down

0 comments on commit 538dcb4

Please sign in to comment.