Open gur0297 opened 1 year ago
import {useParams} from "react-rouert-dom" let { id } = useParams(); const product = products.find((p) => p._id === id);
I want to work on this issue.
tell me full code to fix this
<>
<Row>
<Col sm={12} md={6} lg={4} xl={3}>
{products.map(prod => (
<Product prod={prod} />
))}
</Col>
</Row>
</>
const {id} = useParams();
this will work 100% ---use this before defining the function
Thanks any question email me
On Tue, May 2, 2023, 11:18 PM Jazib Eqbal @.***> wrote:
const {id} = useParams();
this will work 100% ---use this before defining the function
— Reply to this email directly, view it on GitHub https://github.com/bradtraversy/proshop_mern/issues/220#issuecomment-1531937670, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2WHB4YXYR5SUWQOD5DMIV3XEFFXHANCNFSM6AAAAAAWYEDI3U . You are receiving this because you commented.Message ID: @.***>
woking #220
nice also working for me before
import React from 'react' // import {Link} from 'react-router-dom'; // import {Row , Col ,Image , ListGroup , Card , Button } from "react-bootstrap"; // import Rating from "../components/Rating"; import products from "../products"; import {useParams} from 'react-router-dom;
const ProductScreen = () => { const params = useParams(); const product = products.find(p => p._id === params.id); return ( {product.name}
) }
// useParams It make working your project for sure try it once
please help me out because params not defined .
import React from 'react' // import {Link} from 'react-router-dom'; // import {Row , Col ,Image , ListGroup , Card , Button } from "react-bootstrap"; // import Rating from "../components/Rating"; import products from "../products";
const ProductScreen = ({ match }) => { const product = products.find(p => p._id === match.params.id); return (
) }
export default ProductScreen