How can I implement dynamic paths when I click on a link like in a picture?
The user clicks on the link and goes to the message section, then clicks on the link (Link) and goes to the desired component.
DATA:
const data = [
{
link: 'Link Name 1',
text: 'Text 1',
id: '1'
},
{
link: 'Link Name 2',
text: 'Text 2',
id: '2'
},
{
link: 'Link Name 3',
text: 'Text 3',
id: '3'
}
];
App.js
<Switch>
<Route exact path="/" component={AppHome}/>
<Route exact path="/messages" component={AppMessages}/>
<Route exact path="/messages/chat" component={AppMessageItems}/>
<Route exact path="/messages/chat/:id" component={AppMessageItems}/>
</Switch>
Messages.js
const AppMessages = () => {
<ul>
{data.map(function(item, index) {
return (
<li key={index}>
<Link to='/messages/chat'><AppMessageUserList {...item} /></Link>
</li>);
})}
</ul>
}
AppMessageUserList
const AppMessageUserList = ( props ) => {
const {link} = props;
return ( <div> {link} </div> );
}
AppMessageItems.js
const AppMessageItems = () => {
return ( <h1> Hello World </h1> );
}
But when i try this code i get error when click to link.

AppMessageUserList