React this.props.params undefined

后端 未结 6 1218
名媛妹妹
名媛妹妹 2021-02-07 03:15

I have problem passing id to my page with product, I tried everything and search answer but it still doesn\'t work.

Here is my index.js:

impor         


        
6条回答
  •  清歌不尽
    2021-02-07 03:57

    I was also getting the same problem when I used this.props.params.id.

    But when i tried to put console.log(this.props) in the component where I'm passing the id, it shows my id in match object so use:

    this.props.match.params.id
    

    to get the id (notice the added match).

提交回复
热议问题