Extra contents beyond WaniKani
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
614 B

// Hook `usePageContext()` to make `pageContext` available from any Vue component.
// See https://vite-plugin-ssr.com/pageContext-anywhere
import { inject } from 'vue'
import type { App, InjectionKey } from 'vue'
import { PageContext } from './types'
export { usePageContext }
export { setPageContext }
const key: InjectionKey<PageContext> = Symbol()
function usePageContext() {
const pageContext = inject(key)
if (!pageContext) throw new Error("setPageContext() not called in parent")
return pageContext
}
function setPageContext(app: App, pageContext: PageContext) {
app.provide(key, pageContext)
}