I want to display scrollbar when the user first accesses each page
So I tried the code below:
function App() {
const app = document.querySelector("#root");
const [scrollHeight, setScrollHeight] = useState(app?.scrollHeight);
useEffect(() => {
setScrollHeight(app.scrollHeight);
}, [scrollHeight])
if (scrollHeight > window.innerHeight) {
/* show scrollbar and do something */
}
return (/* some components */);
}
Isn't there a better idea?