Navigate through components in reactjs
So i will post 3 images on comments pls check out tell any solutions or ideas
Check images and see code so it would make sense the problem I'm facing
here the code:
navlinks.jsx
Home.js
9 Replies
image 1
image 2
image 3
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^
Unrelated to your question, I’d highly recommend using a button
or a
instead of a p
, for interactivity..Authoring HTML in a JavaScript World by Tony Alicea - Video recordi...
In this talk, Tony shows how an authoring and semantic HTML-first approach to JSX template work leads to more readable, maintainable, and accessible UI components. He demonstrates how to think through implementing a UI prototype in a semantic way, authoring HTML before visuals. He shows how accessible markup improves performance, reduces DOM si...
Where is your NavBar added to HomePage? I don’t see it
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 page
ie compare window.location.pathname to “/projects”, “/“, “/about”, etcI use useNavigate hook , i only send the component code
Ok
By using this, will the page reloads ?
useNavigate is a react router dom method, just fyi.
In Home.js, you have a redirectProjectcs method that navigates to /projects, but it doesn't look like it changes the value of nav, so when NavBar loads, it doesn't know the state should change.
So you can either use a different way to represent the nav state, or some way of passing it down from your home component.
I haven't had to look at RRD for a while and don't know exactly what to suggest.
Yes u r right
I create the state on app.jsx and pass
Thanks