Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No content after refresh #475

Open
KMika-Sages opened this issue Apr 27, 2022 · 5 comments
Open

No content after refresh #475

KMika-Sages opened this issue Apr 27, 2022 · 5 comments

Comments

@KMika-Sages
Copy link

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

@danez
Copy link
Collaborator

danez commented Apr 27, 2022

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

@KMika-Sages
Copy link
Author

KMika-Sages commented May 4, 2022

`

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
Copy link
Author

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

@xSyki
Copy link

xSyki commented Sep 5, 2022

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

@joaobarbosaap
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants