title: Unable to render component in a new page on a new route on button click
body: <p>I am very new to react and just started to build a basic crud application with it. Everything is done besides the update functionality, i got stuck there.I have several bootstrap cards with 2 buttons , delete and update.The data comes from a mysql database and was persisted with hibernate (spring boot on backend).The update button when pressed should pass the id and render a new component(on a different route, guess i need to use Link here) in which a filled form with the respective objects details is presented. Once the user updates the form and clicks submit, he should be redirected to the Cards page. So far i am stuck at the button + Link and rendering the new component phase and for some reason i can't seem to understand how to make it work.This is my code so far</p>
  <p>this is my JSX in which i have the Update button which is in the render method of CarList component which has all the cards.</p>
  <pre><code>&lt;ReactBootstrap.Card.Body&gt;
              &lt;ReactBootstrap.Card.Title&gt;{cars.mark}-{cars.model}&lt;/ReactBootstrap.Card.Title&gt;
                 &lt;ReactBootstrap.Card.Header&gt;Price: {cars.price}&lt;/ReactBootstrap.Card.Header&gt;
                   &lt;br /&gt;
                       &lt;h6&gt;Fabricated: {cars.year}&lt;/h6&gt;
                         &lt;h6&gt;{cars.fuel}&lt;/h6&gt;
                           &lt;ReactBootstrap.Button variant=&quot;success&quot; className=&quot;cardButtons&quot; id=&quot;cardButtonGreen&quot; onClick={() =&gt; this.handleClickUpdate(cars.id)}&gt; Update&lt;/ReactBootstrap.Button&gt;
                           &lt;ReactBootstrap.Button variant=&quot;danger&quot; className=&quot;cardButtons&quot; id=&quot;cardButtonRed&quot; onClick={() =&gt; this.handleClickDelete(cars.id)}&gt; Delete&lt;/ReactBootstrap.Button&gt;
                         &lt;/ReactBootstrap.Card.Body&gt;
                      &lt;/ReactBootstrap.Card&gt;
                 &lt;/div&gt;
               }
          &lt;br /&gt;
     &lt;/div&gt;
  </code></pre>
  <p>this is my CarList class and the constructor</p>
  <pre><code>class CarList extends Component {
  
      constructor(props) {
          super(props)
  
          this.state = {
              cars: [],
              error: &quot;&quot;,
              deleteError: &quot;&quot;,
              updateError: &quot;&quot;,
              updateCarId: null,
              buttonWasPressed: false
          }
      }
  </code></pre>
  <p>here i have the function that is triggered on click.I am sating the state to the id of the object that is in that specific card where the update button is.</p>
  <pre><code>handleClickUpdate = (carId) =&gt; {
          console.log(carId);
          this.setState(
              {
                  updateCarId: carId,
                  buttonWasPressed: true
              }
          )
      }
  </code></pre>
  <p>and lastly i am rendiring the Component MyComp i want to render by passing in the ID.Line is located in component CarList right under where the Card is.</p>
  <pre><code> {this.state.buttonWasPressed &amp;&amp; &lt;MyComp carId={this.state.updateCarId} /&gt;}
  </code></pre>
  <p>What this code gives me so far, is that i am able to set the state as the id, and then use the button to display the component, but it is displayed on the same page, right under the card (where the line of code is also located) instead of displaying it in a new page on a new route.I have tried adding Link,Switch, Route, Router, but i am afraid i am not sure how to use it in this exact context with the button, and it is confusing to me so i was not able to make it work.Can you please help me render &quot;MyComp&quot; on a new page with that id ?
  Any help would be greatly appreciated.</p>