79774213

Date: 2025-09-24 21:49:30
Score: 0.5
Natty:
Report link

I believe it should work to get the pathname (let's say it's const {pathname} = location, I don't use React Router) and then use that as a key:

<Footer isUser={isUser} key={pathname}/>

I guess the other option would be to get the pathname directly in the footer component, and add that to the useEffect hook.

Yes that worked, thankyou. Just to add the answer in my code:

const location = useLocation();

      useEffect(() => {
        let documentHeight = document.documentElement.clientHeight;
        let documentOffsetHeight = window.document.body.offsetHeight;
        console.log("Footer");
        
        if(documentOffsetHeight < documentHeight){
            setFooterPosition({position:'absolute', bottom:0, left:0, right:0, top:documentHeight});
        }else{
            let footerMargin = 0;
            if(isUser){
                footerMargin = 52.5;
            }
            setFooterPosition({marginBottom:footerMargin});
            //setIsAbsolute(false);
        }

      },[location.pathname, isUser])
Reasons:
  • Blacklisted phrase (1): thankyou
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: TY Mathers