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.
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>
)
}
}