0

My router looks like this::

    <Routes>
              <Route path="/:userId" render={(props) => <Home {...props}/>}  element={<Home />} />
    </Routes>

Here is my component::


    import { Component } from 'react'
    export default class Home extends Component {
    
      constructor(props) {
        super(props);
      }
    
      render() {
        console.log(this.match)
        return(
            <div>
              <h2>111</h2>
            </div>
          )
    }
    }

As a result, in the console I get:


    undefined

Question: what am I doing wrong? Why can't I get an id?

  • 1
    https://stackoverflow.com/questions/64782949/how-to-pass-params-into-link-using-react-router-v6 – Inder May 10 '22 at 17:01
  • Does this answer your question? [How to pass params into link using React router v6?](https://stackoverflow.com/questions/64782949/how-to-pass-params-into-link-using-react-router-v6) – Aymen Sep 13 '22 at 14:14

1 Answers1

0

try like this:

console.log(this.props.match)
pinchers
  • 1
  • 1