Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You need to figure out the reason for this error.
Its essence is that you have this.props.match - undefined, which means (most likely, since I don’t see the code) - you render the component not from <Router />
the component (or not from the withRouter wrapper ).
If there is no desire to deal with the reason, and you just want to make a "patch", then you can do this:
componentDidMount() {
if (this.props.match && this.props.match.params.postID) {
const postID = this.props.match.params.postID
axios.get(`http://127.0.0.1:8000/api/${postID}`)
.then(res => {
this.setState({
post: res.data
});
})
}
// если надо можете сделать else
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question