Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

params in showing undefined #220

Open
gur0297 opened this issue Apr 9, 2023 · 9 comments
Open

params in showing undefined #220

gur0297 opened this issue Apr 9, 2023 · 9 comments

Comments

@gur0297
Copy link

gur0297 commented Apr 9, 2023

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
Copy link

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

@DarshanDixit05
Copy link

I want to work on this issue.

@adanyal46
Copy link

tell me full code to fix this

@JazibEqbal
Copy link

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

@JazibEqbal
Copy link

const {id} = useParams();

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

@adanyal46
Copy link

adanyal46 commented May 3, 2023 via email

@Alishan786a
Copy link

woking #220

@adanyal46
Copy link

nice
also working for me before

@KartikAKGEC89
Copy link

KartikAKGEC89 commented Jan 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants