Skip to content

Commit

Permalink
Merge pull request #17251 from Pewtro/b/undefined_docs_context
Browse files Browse the repository at this point in the history
Addon-docs: Ensure that __DOCS_CONTEXT__ cannot be undefined
  • Loading branch information
yannbf committed Feb 21, 2022
2 parents 2e25ba7 + 953eb2d commit 5506ff7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addons/docs/src/blocks/DocsContext.ts
Expand Up @@ -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<DocsContextProps<AnyFramework>> = globalWindow.__DOCS_CONTEXT__;
export const DocsContext: Context<DocsContextProps<AnyFramework>> = globalWindow
? globalWindow.__DOCS_CONTEXT__
: createContext({});

0 comments on commit 5506ff7

Please sign in to comment.