React this.props.params undefined

后端 未结 6 1214
名媛妹妹
名媛妹妹 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-07 04:04

    I assume you are not using react-router v4 but either v2.x.x or v3.x.x. In that case you should restructure your routes and you can pass multiple component using the components props as

       
            
                  
                  
             
        
    

    And in the Menu Component Also the way you want it work is relatively very easy to do using react-router v4. In that case you can make use of prop render to provide a component and you could do the following with it

    import {HashRouter as Router, Route} from 'react-router-dom';
    ...
    
        (
    )}>
    (
    asd
    )}>

提交回复
热议问题