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> {
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e44f22-4c1fe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e44f22-4c1fe.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?