Giter Club home page Giter Club logo

Comments (9)

willmcpo avatar willmcpo commented on May 20, 2024

It should be fixed in recent commits. Please upgrade package to 2.4.2.

Hope that helps.

from body-scroll-lock.

allengordon011 avatar allengordon011 commented on May 20, 2024

I seem to be having this problem too... v2.6.1

from body-scroll-lock.

diachedelic avatar diachedelic commented on May 20, 2024

Are you calling disableBodyScroll with the same element twice, or different elements? Or no elements? @allengordon011

from body-scroll-lock.

allengordon011 avatar allengordon011 commented on May 20, 2024

The same element twice, if I understand your question. I believe it was caused by a re-render on calling setState. I updated the componentDidUpdate so it does not call setState, which fixed the problem.
The funny thing is, I think that code had been working for awhile calling disableBodyScroll twice (and enableBodyScroll twice too).
Thanks for your quick reply @diachedelic

from body-scroll-lock.

diachedelic avatar diachedelic commented on May 20, 2024

Ah @allengordon011 , so was diableBodyScroll was called twice in quick succession?

from body-scroll-lock.

allengordon011 avatar allengordon011 commented on May 20, 2024

Yes, that's right.

from body-scroll-lock.

diachedelic avatar diachedelic commented on May 20, 2024

It seems that because you are supplying the function disableBodyScroll as a click event handler, so the event object is passed as the targetElement argument. targetElement is not optional (see #55) and must be an HTML element.

from body-scroll-lock.

diachedelic avatar diachedelic commented on May 20, 2024

I'm talking about the original repro at https://codesandbox.io/s/0172yjr8n btw, @allengordon011

Just make sure you supply an HTML element to both disableBodyScroll and enableBodyScroll

from body-scroll-lock.

allengordon011 avatar allengordon011 commented on May 20, 2024

FYI my code supplies disableBodyScroll and enableBodyScroll a ref created in the class constructor as
this.modalRef = React.createRef();
componentDidUpdate fires disableBodyScroll if (!prevProps.visible && this.props.visible) and enableBodyScroll if (prevProps.visible && !this.props.visible). Seems to be working now.

from body-scroll-lock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.