diff --git a/.changeset/selfish-lies-cheer.md b/.changeset/selfish-lies-cheer.md new file mode 100644 index 00000000000..47a530b8f33 --- /dev/null +++ b/.changeset/selfish-lies-cheer.md @@ -0,0 +1,5 @@ +--- +'graphiql': patch +--- + +Fixed problem where 'global' variable is referenced when it might not be present (#2155) diff --git a/packages/graphiql/src/components/GraphiQL.tsx b/packages/graphiql/src/components/GraphiQL.tsx index be229f47e1c..117d1cd0fbf 100644 --- a/packages/graphiql/src/components/GraphiQL.tsx +++ b/packages/graphiql/src/components/GraphiQL.tsx @@ -531,7 +531,9 @@ export class GraphiQL extends React.Component { // Utility for keeping CodeMirror correctly sized. this.codeMirrorSizer = new CodeMirrorSizer(); - global.g = this; + if (global) { + global.g = this; + } } UNSAFE_componentWillMount() { this.componentIsMounted = false;