body-scroll-lock icon indicating copy to clipboard operation
body-scroll-lock copied to clipboard

iOS Safari: Attempted to assign to readonly property.

Open BBaysinger opened this issue 5 years ago • 6 comments

Using ES5 version.

[Error] TypeError: Attempted to assign to readonly property. disableBodyScroll (bodyScrollLock.js:1:1391) open (site.js:454) (anonymous function) (site.js:431) dispatch (jquery-3.3.1.min.js:2:41778)

And:

[Error] TypeError: Attempted to assign to readonly property. enableBodyScroll (bodyScrollLock.js:1:2586) close (site.js:638) (anonymous function) dispatch (jquery-3.3.1.min.js:2:41778)

BBaysinger avatar May 17 '19 21:05 BBaysinger

Ugh. My bad. I was passing a string. I'm thinking it should throw an exception from that...

BBaysinger avatar May 17 '19 21:05 BBaysinger

I'm having the same issue while using useRef and passing it value to disableBodyScroll. How have you solved that @BBaysinger ?

yqbk avatar Dec 09 '19 21:12 yqbk

My solution is noted above. Make sure you are not passing a string.

BBaysinger avatar Dec 09 '19 21:12 BBaysinger

In my case the problem was using useRef itself. When I switched to

const targetElement = document.querySelector('#overlay')

It started to work on Safari on iOS without crashing.

yqbk avatar Dec 10 '19 12:12 yqbk

@yqbk I also just ran into this, but I was passing the full ref object. Switching to myRef.current took care of it for me.

jonskeen avatar Dec 10 '19 23:12 jonskeen

@yqbk I also just ran into this, but I was passing the full ref object. Switching to myRef.current took care of it for me.

Works for me too

webdiller avatar Dec 22 '21 06:12 webdiller