So I was reading the solution here: https://stackoverflow.com/Questions/4814398/how-can-i-check-if-a-scrollbar-is-visible
This is what I am going with...
function hasScrollbar() {
console.log(
"hasScrollbar:",
document.body.scrollHeight > document.body.clientHeight
);
return document.body.scrollHeight > document.body.clientHeight;
}
<div
className="landing-top"
style={{ paddingRight: hasScrollbar() ? "0px" : `${scrollBarWidth}px` }}
></div>
However, because of reacts virtual dom, it doesn't seem to be reading it correctly...
Does anyone have any ideas?