Pass object as parameter in Link

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP

Pass object as parameter in Link



I am using <Link> and trying to pass in my thumb_id (if I console log it is just a string value) to my editvideo page as a parameter. How do I accomplish this?


<Link>


thumb_id


editvideo



Code Snippet


const thumbnail, _id = this.props;

return thumbnail.map(thumb => {
console.log(thumb._id);

return (
<div key=thumb._id className="row__inner">
<Link to="/editvideo/:thumb._id">
<div className="tile">
<div className="tile__media">
<img
className="tile__img"
id="thumbnail"
src=thumb.thumbnail
alt=""
/>
</div>
</div>
</Link>
</div>



Params using temp literal



enter image description here



Console log of thumb_id


thumb_id




1 Answer
1



You can use a template literal to insert the value of the variable in the string.


template literal


<Link to=`/editvideo/$thumb._id`>





Okay, I tried that but the thumb_id itself is being passed as the param instead of the id (I updated my code and added a screenshot of my console)
– The_Enigma
2 days ago



thumb_id





@The_Enigma Do you want the _id from the props in all Link components, instead of the thumb._id?
– Tholle
2 days ago


_id


Link


thumb._id





I want it for a specific component. So pretty much my code generates thumbnail tiles. When I click on them I want to pass the thumb._id as a parameter to my page Link so then I can get data specific to that id.
– The_Enigma
2 days ago


thumb._id


Link


id





I also updated my description with a screenshot of the console log of thumb_.id because I assumed since I just console.log it and its a string value I could do it was you suggested.
– The_Enigma
2 days ago


thumb_.id


console.log





I LOVE YOU, I didn't freaking see that.
– The_Enigma
2 days ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

Executable numpy error

Trying to Print Gridster Items to PDF without overlapping contents

Mass disable jenkins jobs