problem description
I just started to learn that react, got stuck here when passing parameters in react-router4. Please help me.
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)
this
import React from "react";
export default class ComponentList extends React.Component {
constructor (props){
super(props)
console.log(this.props.match.params.id);
}
render(){
return(
<div>
<h2></h2>
<h2>id: {this.props.match.params.id}</h2>
</div>
)
}
}
what result do you expect? What is the error message actually seen?
is to get the parameter id,/index.html-sharp/user/123123 on url: this 123123.
console.log (this.props.match.params.id); this sentence can type out 123123.
but < H2 > id is: {this.props.match.params.id} < / H2 > the error is reported here.
how should I write to get this id parameter in return? Please ask for advice