title: React Router : Dynamically url id
body: <p><a href="https://i.stack.imgur.com/gyLGg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gyLGg.png" alt="enter image description here"></a></p>
  
  <p>How can I implement dynamic paths when I click on a link like in a picture?</p>
  
  <p>The user clicks on the link and goes to the message section, then clicks on the link (Link) and goes to the desired component.</p>
  
  <p><strong>DATA:</strong></p>
  
  <pre><code>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'
      }
      ];
  </code></pre>
  
  <p><strong>App.js</strong></p>
  
  <pre><code>&lt;Switch&gt;
   &lt;Route exact path="/" component={AppHome}/&gt;
   &lt;Route exact path="/messages" component={AppMessages}/&gt;
   &lt;Route exact path="/messages/chat" component={AppMessageItems}/&gt;
   &lt;Route exact path="/messages/chat/:id" component={AppMessageItems}/&gt;
  &lt;/Switch&gt;
  </code></pre>
  
  <p><strong>Messages.js</strong></p>
  
  <pre><code>const AppMessages = () =&gt; {
               &lt;ul&gt;
                  {data.map(function(item, index) {
                      return (
                          &lt;li key={index}&gt;
                              &lt;Link to='/messages/chat'&gt;&lt;AppMessageUserList {...item} /&gt;&lt;/Link&gt;
                          &lt;/li&gt;);
                  })}
              &lt;/ul&gt;
  }
  </code></pre>
  
  <p><strong>AppMessageUserList</strong> </p>
  
  <pre><code>const AppMessageUserList = ( props ) =&gt; {
  const {link} = props;
     return ( &lt;div&gt; {link} &lt;/div&gt; );
  
  }
  </code></pre>
  
  <p><strong>AppMessageItems.js</strong></p>
  
  <pre><code>const AppMessageItems = () =&gt; {
     return ( &lt;h1&gt; Hello World &lt;/h1&gt; );
  
  }
  </code></pre>
  
  <p>But when i try this code i get error when click to link.</p>