use props.match.params in a class

Asked

Viewed 122 times

0

I would like to use a function that is within a class, but I would like this function to use the props.match.params to rescue the id of the product in the URL, to know which product the function will handle and etc.

class Exemplo{

    exemplo(){
        const id = props.match.params
        return console.log(id)
    }
}
export default new Exemplo()

When I try to execute a code similar to this, type error "props Undefined"

  • Your routes are configured?

  • Just remembering that the props is in context this.props. React props

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.