react-tabs icon indicating copy to clipboard operation
react-tabs copied to clipboard

No content after refresh

Open KMika-Sages opened this issue 4 years ago • 6 comments

When Im on different tab than first, when I refresh the page, there is weird error where no content on any tab is visible, and first tab is underlined as active. image

As you can see in the picture there is content in console in third tab, but the panel is not active. Can you give me inside on this?

I can share the code.

For url params i use use-query-params

KMika-Sages avatar Apr 27 '22 12:04 KMika-Sages

Can you please share an example? If I look at the code of the TabPanel this should not be possible.

danez avatar Apr 27 '22 17:04 danez

`

const FinanceTabPanel = (props: any) => {
const { edges, financeCategories } = props
const FINANCE_CATEGORIES: string[] = financeCategories

const [tab, setTab] = useQueryParam("tab", withDefault(StringParam, FINANCE_CATEGORIES[0]))
const selectedTabIndex = edges.map(panel => panel.node.financeTabId).indexOf(tab)

const handleTabChange = (newTabIndex: number) => {
    if (newTabIndex !== selectedTabIndex) {
        setTab(FINANCE_CATEGORIES[newTabIndex])
    }
}

return (
    <section className="finance-section">
        <div className="tab-panel_wrapper">
            <Tabs selectedIndex={selectedTabIndex} onSelect={handleTabChange}>
                <TabList>
                    {edges.map((tab: FinancePropsProperties, idx: number) => (
                        <Tab key={idx}>{tab.node.financeTabName}</Tab>
                    ))}
                </TabList>

                {edges.map((tab: FinancePropsProperties, index: number) => (
                    <TabPanel key={index}>
                        <FinanceTarget props={edges[index]} />
                        {tab.node?.trainingITTopics ? (
                            <OpenTrainingsTopics props={edges[index]} />
                        ) : (
                            <React.Fragment />
                        )}
                        {tab.node?.financeApplicationTitle ? (
                            <FinanceApplication props={edges[index]} />
                        ) : (
                            <React.Fragment />
                        )}
                        {tab.node?.recruitment ? <Recruitment props={edges[index]} /> : <React.Fragment />}
                        {tab.node?.financeDownloadableFiles ? (
                            <DownloadFiles props={edges[index]} />
                        ) : (
                            <React.Fragment />
                        )}
                        {tab.node?.informationReference ? (
                            <InformationReference props={edges[index]} />
                        ) : (
                            <React.Fragment />
                        )}
                    </TabPanel>
                ))}
            </Tabs>
        </div>
    </section>
)

} `

KMika-Sages avatar May 04 '22 12:05 KMika-Sages

Can you please share an example? If I look at the code of the TabPanel this should not be possible.

And if you want live example then go https://www.sages.pl/blog Choose tab different than first and refresh page

KMika-Sages avatar May 06 '22 08:05 KMika-Sages

@danez I had the same problem. Updating to a new version of react-tabs and react helped. I think you can close this issue.

xSyki avatar Sep 05 '22 17:09 xSyki

Looks like your problem is related with your application state, when I refresh your website after your example I can see a blank screen, but if you check the UI, you will notice that the first tab is selected, and your URL is requesting the data for another tab, so you need to sync your tab with your current URL in order to fix it.

joaobarbosaap avatar Sep 08 '22 20:09 joaobarbosaap

Looks like your problem is related with your application state, when I refresh your website after your example I can see a blank screen, but if you check the UI, you will notice that the first tab is selected, and your URL is requesting the data for another tab, so you need to sync your tab with your current URL in order to fix it.

how do i do that

Uzayry42 avatar Jan 02 '25 03:01 Uzayry42