The error will be prompted if the generic this.props.match is not set at the end of the react+typescript class.

just learning typescript
creating a project with ts+react_react-router encounters the following problems when using react-router "s this.props.match. I hope you can give me some advice:

if the generic this.props.match is not set after the react+typescript class, it will prompt an error
there is no match attribute

setting the props type to IProps in the constructor parameter is also invalid.

clipboard.png

    import * as React from "react"
import "./index.less"

interface IProps {
    match?: any
}
export default class Home extends React.Component {
    constructor(props:IProps) {
        super(props)
    }
    public componentDidMount() {
        // react-router match url
        console.log("url :", this.props.match) 
    }
    public render () {
        return (
            <div className="home-wrap">
                , XXX
            </div>
        )
    }
}
Jun.30,2021

@ types/react-router

you need to use withRouter
in the component when you want to use H5 jump in V4. In Ts, you need to inherit RouteComponentProps this interface in the Props interface:

interface IArticleProps extends RouteComponentProps {
  match: {
    isExact: boolean
    params: { id: any }
    path: string
    url: string
  }
}

class Article extends React.Component<IArticleProps> {
Menu