question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using headers prop creates new tab on every reload

See original GitHub issue

I’ve created a repro here: https://stackblitz.com/edit/react-ts-9dagjc?file=GraphiQL.tsx

Try hitting the refresh button on the preview on the right. It seems when i remove the headers prop the problem disappears.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
thomasheyenbrockcommented, Aug 26, 2022

Thanks @spawnia for surfacing this, can confirm that this appears again, reopening the issue and looking into it 👀

0reactions
thomasheyenbrockcommented, Sep 28, 2022

Hey @sdcoffey 👋 let me elaborate a bit on the behavior of the props that set the editor values (query, variables and headers).

When initially rendering GraphiQL, there are two sources where we could read the editor values from: The props I just mentioned and the latest state of all the tabs persisted in localStorage. When these props are not set, GraphiQL just restores the state from localStorage. If one of them is set, there are two cases:

  • The values provided via props match some of the tabs in localStorage. GraphiQL will choose this tab to be the active one.
  • The values provided via props match none of the tabs in localStorage. GraphiQL will then create a new tab with the values provided via props and choose this to be the active one.

To summarize: If you set at least one of the props query, variables or headers, then GraphiQL will open up a new tab when reloading if the value of the props during the initial render don’t match the latest persisted state before reloading.


All the above was a general explanation about the behavior when GraphiQL creates new tabs on reload. I’m necessarily sure that this resolves your issue, but I think this is valuable information related to the behavior of GraphiQL with tabs (also for others that might find this issue in the future).

So, given this context, does that explain the behavior you’re seeing? If not, can you provide a reproduction so that we can debug this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ContextAPI loses state on page reload and when opened in ...
The issue is that when I reload/open a component (these are dependent on the state that is passed from the context Provider) in...
Read more >
How to Build a Tabs Component with React - DigitalOcean
In this step, you will create a new folder and the Tabs component that will render each Tab . First, create a folder...
Read more >
Working with the Tabs API - Mozilla - MDN Web Docs
Discovering more about tabs and their properties using tabs.query . Creating, duplicating, moving, updating, reloading, and removing tabs.
Read more >
How to Make a Modal Popup Refresh Items on the Page
The above reload() method forcefully reloads the page by invoking the built-in reload method on the browser's global object (the window object) ...
Read more >
How to Open URL in New Tab using JavaScript
Do not add a third parameter to it as it will result in the opening of a new window rather than a tab....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found