Uncaught TypeError: Cannot read properties of undefined (reading 'params')
Unabel to navigate to id can anyone help?
i am woriking on django as backend and react as frontend
class ArticleDetail extends  React.Component{

    state={
        article:{}
    }
    componentDidMount(){
        const id = this.props.match.params.id;
      
      axios.get(`http://127.0.0.1:8000/api/${id}`)
      .then(res =>{
        this.setState({
            article:res.data
        });
        console.log(res.data)
       
      })

    }
    render(){
        return(
           
            <Card title={this.state.article.title} >
                <p>{this.state.article.content }</p>
            </Card>
        )
    }
}```


TypeError: Cannot read properties of undefined (reading 'params') Unabel to navigate to id can anyone help?
i am working on react + django. My data from server in list is showing but when i try to navigate to particular data id it shows error


TypeError: Cannot read properties of undefined (reading 'params') Django + React
This should be a frontend problem.
1-) Add the following line of code at the beginning of your class:
import { useParams } from 'react-router-dom';

2-) Then add this function above your class (copy it exactly):
 export function withRouter(Children){
 return(props)=>{

    const match  = {params: useParams()};
    return <Children {...props}  match = {match}/>
  }
 }

3-) Next, change your class definition to this:
class ArticleDetail extends Component

4-) Add the following line of code at the end of your class:
export default withRouter(ArticleDetail);

Ref: https://stackoverflow.com/a/75304487/11897778
If it doesn't work, please provide more details about the error, if the API request is being made or is it failing before making the API request?
