2

There a lot of threads online about how to lock the body especially on iOS, but I haven't found a good answer.

body {
overflow: hidden;
}

Doesn't work on iOS.

My question is: how can I prevent Body Scrolling on iOS with react-modal?

Note: I found this package that it might work, but the problem is that I can't find a way to make it work with react-modal and hooks.

https://github.com/willmcpo/body-scroll-lock

Any help?

Alfrex92
  • 6,278
  • 9
  • 31
  • 51
  • Bad news: it's not a trivial one-liner to get that to work across different devices such as chrome desktop and mobile safari. Good news: plenty of packages do that for you, such as the aforementioned body-scroll-lock. There are bound to be react-modal alternatives that come with scroll lock built-in as well, so I'd suggest your look for a modal/scroll-lock package that works for you or look into the source code of a package like body-scroll-lock to try and understand how to code that yourself. – xddz9 Oct 09 '20 at 05:02

0 Answers0