Next.js Discord

Discord Forum

Render something after the user clicks on it

Answered
Pacific herring posted this in #help-forum
Open in Discord
Pacific herringOP
Basically I get some data from the database and render it on the screen, then when the user clicks on the data, it should pop up some more info in another section of my page.

If you look at the image, oon the left I have Datas, on the right I have a screen where I should render the clicked data info (in this case, data 3).

8 Replies

Pacific herringOP
Is it possible to "update" a component? like this thing might happen or not, its up to the user
Aleutian Tern
yes, you can think the left side will be client side the navigation, the right side component is responsible to loading the data. You could make the right side component read the id from the URL, the left side component would be the client component that will update the url using "useRouter()"
Answer
Pacific herringOP
As id from URL you mean slugs?
I forgot to say that the left side has an ID already (<component id={id} />
Aleutian Tern
You need to provide more info about your code if you already tried to implement it and isn't working.
@Aleutian Tern You need to provide more info about your code if you already tried to implement it and isn't working.
Pacific herringOP
Actually i have never tried Dynamic routes and i dont know why LOL