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

How to import "fullpageApi" method from @fullpage/react-fullpage without the "render" method? #264

Open
ilya-maker opened this issue Aug 11, 2021 · 8 comments

Comments

@ilya-maker
Copy link

ilya-maker commented Aug 11, 2021

I want set this method in state without render

<ReactFullpage
      pluginWrapper={pluginWrapper}
      licenseKey=''
      scrollingSpeed={1000}
      scrollHorizontallyKey=''
      scrollHorizontally={true}
      controlArrows={false}
      anchors={['home']}
      loopHorizontal={false}
      render={({ state, fullpageApi }) => {
        dispatch(setFullpageApi(fullpageApi))
        return ()}}
/>

Something like this.
import ReactFullpage, { fullpageApi } from "@fullpage/react-fullpage";
dispatch(setFullpageApi(fullpageApi))

@alvarotrigo
Copy link
Owner

Can you use the window global object instead?
fullpage_api?

@ilya-maker
Copy link
Author

No, window.fullpage_api is undefined.
I have a main page with ReactFullpage and a navbar with links to the main page.
But when I go to another page and click on the link in the navbar, I get fullpage_api is undefined.

@alvarotrigo
Copy link
Owner

Any idea @cmswalker ?

@ilya-maker
Copy link
Author

So can you help me?

@alvarotrigo
Copy link
Owner

You can try creating a codesanbox with the reproduction.
Perhaps this way we can help you better.

@gymgym1212
Copy link

Hi @alvarotrigo , I'd like to share some experience about fullpage_api

You can see my comments in codesandbox

My experience is using window.fullpage_api not fullpage_api. I am still wondering why fullpage_api only works in codesandbox but my vscode.

afterRender={() => {
      // 'fullpage_api' is not defined. 
      // It works in codesandbox but my vscode.
      fullpage_api.setAllowScrolling(false);

      // It works both in codesandbox and my vscode.
      window.fullpage_api.setAllowScrolling(false);
}}

@ilya-maker May it help you.

@gosxrgxx
Copy link

gosxrgxx commented Feb 8, 2022

I am dealing with the same problem. Is there a solution for this?

@alvarotrigo
Copy link
Owner

I am dealing with the same problem. Is there a solution for this?

Just use window.fullpage_api as suggested in the last answer.

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