Skip to content

Commit 3acacf5

Browse files
patrick91acao
authored andcommitted
Instantiate isHeadersEditorEnabled early
1 parent a785730 commit 3acacf5

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

.changeset/wise-pans-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'graphiql': patch
3+
---
4+
5+
Fix cannot access `initialHeaders` before initialization

packages/graphiql/src/components/GraphiQL.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ export type GraphiQLInterfaceProps = WriteableEditorProps &
195195
};
196196

197197
export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
198+
const isHeadersEditorEnabled = props.isHeadersEditorEnabled ?? true;
199+
198200
const editorContext = useEditorContext({ nonNull: true });
199201
const executionContext = useExecutionContext({ nonNull: true });
200202
const schemaContext = useSchemaContext({ nonNull: true });
@@ -305,8 +307,6 @@ export function GraphiQLInterface(props: GraphiQLInterfaceProps) {
305307
isChildComponentType(child, GraphiQL.Footer),
306308
);
307309

308-
const isHeadersEditorEnabled = props.isHeadersEditorEnabled ?? true;
309-
310310
const onClickReference = () => {
311311
if (pluginResize.hiddenElement === 'first') {
312312
pluginResize.setHiddenElement(null);

0 commit comments

Comments
 (0)