Reputation: 37
I'm trying to get a link to generate a dynamic query string. The list is rendering the record within a map loop, but I can't seem to render the variable inside the Link
tag. In the browser it shows {record.idea_uniqueid}
.
<Link to="/searchIdeaDetail?IUI={record.idea_uniqueid}">
<ListItem>
<Avatar><WorkIcon /></Avatar>
<ListItemText primary={record.ideaName} secondary={record.lkpEmail} />
</ListItem>
</Link>
Upvotes: 0
Views: 100
Reputation: 2482
You should write like following:
<Link to={`/searchIdeaDetail?IUI=${record.idea_uniqueid}`}>
<ListItem>
<Avatar><WorkIcon /></Avatar>
<ListItemText primary={record.ideaName} secondary={record.lkpEmail} />
</ListItem>
</Link>
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
Upvotes: 0
Reputation: 4139
change
<Link to="/searchIdeaDetail?IUI={record.idea_uniqueid}">
to
<Link to={`/searchIdeaDetail?IUI=${record.idea_uniqueid}`}>
Upvotes: 1