React Router Pass Param to Component

后端 未结 10 1275
南方客
南方客 2020-11-30 20:06
const rootEl = document.getElementById(\'root\');

ReactDOM.render(
    
        
            
              


        
10条回答
  •  无人及你
    2020-11-30 20:57

    I used this to access the ID in my component:

    
    

    And in the detail component:

    export default class DetailsPage extends Component {
      render() {
        return(
          

    {this.props.match.params.id}

    ) } }

    This will render any ID inside an h2, hope that helps someone.

提交回复
热议问题