cmswalker / fullpage-react

Stateful fullpage.js inspired scrolling for React
https://cmswalker.github.io/fullpage-react/
206 stars 42 forks source link

Fullpage fails on changing to another Fullpage path #65

Closed elverskog closed 6 years ago

elverskog commented 6 years ago

If I have two pages/routes using Fullpage, and try to change routes from one to another, I get a series of errors in main FullpageReact.js file regarding the line: window.removeEventListener('resize', this.resize.bind(this));

Just adding a check seems to fix this. Any chance you can add something similar to your repo?

    //exit if we can't find window or resize function
    //this fixes issue when changing from route to route that both have Fullpage in use
    if (!window || typeof this.resize !== 'function') {
      return;
    }
cmswalker commented 6 years ago

I see. Do you have a repo I can reproduce with or should this manifest itself with react router boilerplate?

elverskog commented 6 years ago

Our repo isn't public. I wanted to check to see it wasn't my code, so I cloned your example and duplicated the fullpageReactExample.js page and then stuck a parent component above the two pages. Adding react-router, react-router-dom and creating a to each page. The error occurred the same as in my code base.

Fullpage.js:319 Uncaught TypeError: Cannot read property 'bind' of undefined

I used the latest react-router. If you need anything else please let me know.

Thanks.

cmswalker commented 6 years ago

Fixed. Here is an example that has been tested https://github.com/cmswalker/fullpage-react/blob/781e6bd15e0ff6b0b30bc5c84256022916269f42/examples/fullpageReactExample.js

cmswalker commented 6 years ago

fixed in v3.0.24