body-scroll-lock
body-scroll-lock copied to clipboard
iOS Safari: Attempted to assign to readonly property.
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)
Ugh. My bad. I was passing a string. I'm thinking it should throw an exception from that...
I'm having the same issue while using useRef
and passing it value to disableBodyScroll
. How have you solved that @BBaysinger ?
My solution is noted above. Make sure you are not passing a string.
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 I also just ran into this, but I was passing the full ref object. Switching to myRef.current
took care of it for me.
@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