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

fullpage_api doesn't exist on window #404

Open
devAdrish opened this issue Mar 22, 2023 · 5 comments
Open

fullpage_api doesn't exist on window #404

devAdrish opened this issue Mar 22, 2023 · 5 comments

Comments

@devAdrish
Copy link

Description

I am using Next.js and typescript. When I try to access fullpage_api, it gives me following error:
'Property 'fullpage_api' does not exist on type 'Window & typeof globalThis'

image

Although it works when running locally, build fails.

image

Versions

Fullpage Version 0.1.36

@alvarotrigo
Copy link
Owner

Where are you trying to execute it?

If you are inside the render function of the fullpage component you can use fullpageApi instead.

@alvarotrigo
Copy link
Owner

Can you try adding this on /types/index.d.ts on the react-fullpage component folder and let me know if it fixes it for you?

declare global {
    interface Window {
        fullpage_api:any;
    }
}

@devAdrish
Copy link
Author

Did try this, fullpage-api becomes undefined.
And yes, works inside the render function, but should be available outside of it.
Can you not export this api from the package so one can import it and use it.
Y'know something like import { fullpage-api } from '@fullpage/react-fullpage.

@alvarotrigo
Copy link
Owner

Did try this, fullpage-api becomes undefined.

It's with underscore: fullpage_api

@alvarotrigo
Copy link
Owner

Can you not export this api from the package so one can import it and use it.

I'll be happy to merge a pull request if you think that's an option.

Note however that the variable window.fullpage_api is created dynamically once fullpage.js gets initialized, so it just doesn't exist before this step.

@cmswalker what are your thoughts on this?

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

No branches or pull requests

2 participants