alvarotrigo / react-fullpage

Official React.js wrapper for fullPage.js https://alvarotrigo.com/react-fullpage/
GNU General Public License v3.0
1.29k stars 178 forks source link

Throws error after rout change #399

Closed zewas-digital closed 1 year ago

zewas-digital commented 1 year ago

Description

After a rout Change it throws the error: "TypeError: can't access property "index", this.state.destination is undefined" on "node_modules/@fullpage/react-fullpage/dist/react-fullpage.js (92:463)"

This is the code of the page:

return (
    <>
        <Seo meta={blok?.meta} />

        <StyledPage {...props} path={router.asPath}>
            {!blok?.disableHeader && <Header blok={header} />}
            {router.asPath == "/" || router.asPath.includes("/#") ? (
                <ReactFullpage
                    anchors={anchors}
                    navigation
                    navigationTooltips={anchors}
                    licenseKey={process.env.FULLPAGE_API_KEY}
                    onLeave={(origin, destination, direction, trigger) => {
                        console.log(trigger);
                    }}
                    render={({ state, fullpageApi }) => {
                        return (
                            <div>
                                {blok.body
                                    ? blok.body.map((blok) => <StoryblokComponent {...props} blok={blok} key={blok._uid} footer={footer} />)
                                    : null}
                            </div>
                        );
                    }}
                />
            ) : blok.body ? (
                blok.body.map((blok) => <StoryblokComponent {...props} blok={blok} key={blok._uid} footer={footer} />)
            ) : null}
            {/* {!blok?.disableFooter && <Footer blok={footer} path={router.asPath} />} */}
        </StyledPage>
    </>
);

Steps to reproduce it

  1. You open Website:Qualityhosts
  2. Then you change the page by clicking on "Impressum" at the footer
  3. You now use your browsers back arrow to chang the page to the last one visited

Versions

react: 18.2.0 next: ^13.0.5 @fullpage/react-fullpage: ^0.1.34, Browser: Firefox 111.0b8 Operatingsystem: macOS Ventura V13.2.1 Device: MacBook Pro 2021 Chip: Apple M1 Pro

alvarotrigo commented 1 year ago

Thanks for reporting it! It indeed looks like a bug.

Can you try updating to the new version I just released? 0.1.35

Let me know if that works for you.

zewas-digital commented 1 year ago

Hey, I just updated to V 0.1.35 and another Error occured. This time it's diplaying: "Unhandled Runtime Error

TypeError: n.parentNode is null Call Stack T node_modules/@fullpage/react-fullpage/dist/react-fullpage.js (238:2669)"

alvarotrigo commented 1 year ago

I can't see any error on the website when doing the same steps as before: https://qha.zewas.at/en

How can I reproduce the issue?

zewas-digital commented 1 year ago

Yeah you are right. Locally we had the problem I assume it was because of the package next/link we use for links but i was not 100% sure.

But the Issue is resolved now. Thank you for the fast response and providing a Solution.