Zec
KPCKevin Powell - Community
•Created by vic on 8/7/2024 in #front-end
Navigate through components in reactjs
ie compare window.location.pathname to “/projects”, “/“, “/about”, etc
19 replies
KPCKevin Powell - Community
•Created by vic on 8/7/2024 in #front-end
Navigate through components in reactjs
I’d recommend using
window.location.pathname
for URL tracking instead of React state; it’s managed for you (by the browser), it won’t get lost when the navbar unmounts from the DOM, and should stay consistent with the current page19 replies
KPCKevin Powell - Community
•Created by vic on 8/7/2024 in #front-end
Navigate through components in reactjs
Where is your NavBar added to HomePage? I don’t see it
19 replies
KPCKevin Powell - Community
•Created by vic on 8/7/2024 in #front-end
Navigate through components in reactjs
19 replies
KPCKevin Powell - Community
•Created by vic on 8/7/2024 in #front-end
Navigate through components in reactjs
Unrelated to your question, I’d highly recommend using a
button
or a
instead of a p
, for interactivity..19 replies
KPCKevin Powell - Community
•Created by vic on 8/7/2024 in #front-end
Navigate through components in reactjs
Where does
useNavigate
get imported from? Many navigation libraries have a router system that you can use, so you don’t have to implement it yourself^19 replies