diff --git a/addons/docs/src/blocks/DocsContext.ts b/addons/docs/src/blocks/DocsContext.ts index 3fada361a323..e539f2739c6e 100644 --- a/addons/docs/src/blocks/DocsContext.ts +++ b/addons/docs/src/blocks/DocsContext.ts @@ -12,9 +12,11 @@ export type { DocsContextProps }; // the React component tree. // This was specifically a problem with the Vite builder. /* eslint-disable no-underscore-dangle */ -if (globalWindow.__DOCS_CONTEXT__ === undefined) { +if (globalWindow && globalWindow.__DOCS_CONTEXT__ === undefined) { globalWindow.__DOCS_CONTEXT__ = createContext({}); globalWindow.__DOCS_CONTEXT__.displayName = 'DocsContext'; } -export const DocsContext: Context> = globalWindow.__DOCS_CONTEXT__; +export const DocsContext: Context> = globalWindow + ? globalWindow.__DOCS_CONTEXT__ + : createContext({});