0

I would like to pass information through the Link tag to another component . However , i am unable to after watching several tutorials .

function Productscard(props) {
  return (
   <div className="item">
      <Link to = "/products_info">
      <div className="item_container">
<h3 className="subcategory_Tag"> {props.subcategory}</h3>
<h2 className="name_tag"> {props.name}</h2>
<img src={photo} alt="" className="photo" />
<h3 className="price_tag">$399.99 - $500</h3>

</div>
</Link>



   </div>)
}

export default Productscard

There are several Productscard components being rendered on the page . Upon being clicked , they should take me to the products_info page and display product name and description . I have attempted unsuccessfully and below is my product_info component -


function Product_info(props) {
  const params = useParams();

  return (
 <div className="product_info">

<h1>
         {params.name} 
      </h1>



 </div>
  )
}

export default Product_info

I have also set the route in app js

          <Route path="/products_info element={<Product_info />}/>

I have tried the above code unsuccessfully

2
  • can you add what error are you getting, i can see you are invalid html in app.js Please update to the following and test if it works <Route path="/products_info" element={<Product_info />}/> Commented Nov 8, 2022 at 3:36
  • Please create a sandbox link so i can test and help you around Commented Nov 8, 2022 at 3:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.