Here's a barebones example of what I'm working with:
https://codesandbox.io/s/peaceful-faraday-xl3kz0?file=/src/Tabs.js
import { Tab } from "@headlessui/react";
export default function Tabs() {
return (
<Tab.Group>
<Tab.List>
<Tab>Tab 1</Tab>
<Tab>Tab 2</Tab>
<Tab>Tab 3</Tab>
</Tab.List>
<Tab.Panels>
<Tab.Panel>Content 1</Tab.Panel>
<Tab.Panel>Content 2</Tab.Panel>
<Tab.Panel>{renderIframe()}</Tab.Panel>
</Tab.Panels>
</Tab.Group>
);
function renderIframe() {
return (
<iframe
src="https://en.wikipedia.org/wiki/Main_Page"
height="800px"
width="800px"
title="Example"
loading="eager"
></iframe>
);
}
}
If you click on tab 3, you should see an iframe pointed at Wikipedia. However, if you navigate to another page within the iframe ('Current events', for example), and then click on tab 1, and then click on tab 3 again, the iframe will load the Wikipedia home page again. Is there a way for me to maintain the state of this iframe so that even after I change tabs, it's exactly the same as it was before when I go back to tab 3?