title: React pass fetched data from API to another component
body: <p>I am fetching few products from an API, and displaying them in card. There is a More Details link on the cards, where if the user clicks on it, it will take the user to the selected product details page. My routing to productDetails page works, But I am having troubles to find a way to pass the fetched data to the productDetails page as props.</p>
  <p>This is what I have so far:
  My FeaturedProduct.js:</p>
  <pre><code>import React from &quot;react&quot;;
  import { useState, useEffect } from &quot;react&quot;;
  import { BrowserRouter as Router, Route, Link, Switch } from &quot;react-router-dom&quot;;
  import ProductDetails from &quot;./ProductDetails&quot;;
  import axios from &quot;axios&quot;;
  
  function FeaturedProduct(props) {
    const [products, setProducts] = useState([]);
   
    useEffect(() =&gt; {
      fetchProducts();
    }, []);
  
    function fetchProducts() {
      axios
        .get(&quot;https://shoppingapiacme.herokuapp.com/shopping&quot;) 
        .then((res) =&gt; {
          console.log(res); 
          setProducts(res.data);
        })
        .catch((err) =&gt; {
          console.log(err);
        });
    }
    return (
      &lt;div&gt;
        &lt;h1&gt; Your Products List is shown below:&lt;/h1&gt;
        &lt;div className=&quot;item-container&quot;&gt;
         
          {products.map((product) =&gt; (
            &lt;div className=&quot;card&quot; key={product.id}&gt;
              {&quot; &quot;}
             
              &lt;h3&gt;{product.item}&lt;/h3&gt;
              &lt;p&gt;
                {product.city}, {product.state}
              &lt;/p&gt;
              &lt;Router&gt;
                &lt;Link to=&quot;/productdetails&quot;&gt;More Details&lt;/Link&gt;
  
                &lt;Switch&gt;
                  &lt;Route path=&quot;/productdetails&quot; component={ProductDetails} /&gt;
                &lt;/Switch&gt;
              &lt;/Router&gt;
            &lt;/div&gt;
          ))}
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
  
  export default FeaturedProduct;
  </code></pre>
  <p>My Product Details Page:</p>
  <pre><code>import React from &quot;react&quot;;
  import FeaturedProduct from &quot;./FeaturedProduct&quot;;
  
  function ProductDetails(props) {
    return (
      &lt;div&gt;
        &lt;div&gt;
          &lt;h1&gt;{props.name}&lt;/h1&gt;
          &lt;h1&gt;{props.color}&lt;/h1&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
  export default  ProductDetails;
  </code></pre>