bradtraversy / proshop_mern

Shopping cart built with MERN & Redux
2k stars 1.18k forks source link

params in showing undefined #220

Open gur0297 opened 1 year ago

gur0297 commented 1 year ago

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 (

{product.name}

) }

export default ProductScreen

adanyal46 commented 1 year ago

import {useParams} from "react-rouert-dom" let { id } = useParams(); const product = products.find((p) => p._id === id);

DarshanDixit05 commented 1 year ago

I want to work on this issue.

adanyal46 commented 1 year ago

tell me full code to fix this

JazibEqbal commented 1 year ago
<>
  <Row>
    <Col sm={12} md={6} lg={4} xl={3}>
    {products.map(prod => (
        <Product prod={prod} />
    ))}
    </Col>
  </Row>
</>
JazibEqbal commented 1 year ago

const {id} = useParams();

this will work 100% ---use this before defining the function

adanyal46 commented 1 year ago

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: @.***>

Alishan786a commented 11 months ago

woking #220

adanyal46 commented 11 months ago

nice also working for me before

KartikAKGEC89 commented 9 months ago

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