We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Same problem here. Found a little workaround here:
const handleScroll = () => {
if (stickyRef.current) {
window.pageYOffset > stickyRef.current.getBoundingClientRect().bottom
? setSticky(true)
: setSticky(false);
}
};
I have fixed the bugs and also updated the sticky effect with a custom hook.
scroll listener was not getting removed when component was unmounted. I used useCallback for fixing it:
const scrollHandler = useCallback(() => {
debounce(handleScroll())
}, [])
useEffect(() => {
if (location.pathname === '/') {
window.addEventListener("scroll", scrollHandler)
return () => {
window.removeEventListener("scroll", scrollHandler)
}
}
}, [debounce, handleScroll]);
I simply used the bootstrap property, fixed="top"
<navbar id="nav" fixed="top" expand="lg" bg="light" variant="light">
Hi mate. Nice idea but it is a bit of a muddle now... The original code (as per this post) didn't run - some issue with the rendering of Welcome.js - but there isn't a render in that file. ??
The latest build from your github account has additional require statements in the index.js module. You will need to update this post to include the extra npm i express/next/path/fs modules (I assume that is what the missing module errors mean - but I am a newbie at this!
After installing the extra modulesmpm i get an error "./src/index.js Error: ENOENT: no such file or directory, open '/Users/Srjones/0_W4web/w4web/react-sticky-navbar/src/index.js'
I moved this back to the first level folder - now I get a missing module 'cors'
I installed cors - the app compiled but renders just this error: 'Cannot get /'
There is no index.html file in this project... Even if I add one I still get the same error
This is the third navbar code I have tried today - none of them work!
any suggestions would be welcomed - I really don't want to use bootstrap if I can help it...
https://uploads.disquscdn.c...
The same error
This error is related to the `ref`, the element is not selected, try to check if it refers to the element.
Can you please share a link to your code?
I keep getting the Cannot read property getBoundingClientRect of null, even though i set a div to have a ref of StickyRef