react-router跳转页面

import { withRouter, RouteComponentProps } from 'react-router'  //RouteComponentProps为路由的参数
const dispatchProps = {
  loginSuccess,
}
type SigninProps = typeof dispatchProps & RouteComponentProps
class Signin extends React.Component {
  componentDidMount() {
    this.props.history.push('/dashboard')
  }

...

}

...

export default withRouter( //使用withRouter向组件传递RouteComponentProps
  connect(
    undefined,
    dispatchProps,
  )(Signin),
)

你可能感兴趣的:(react-router跳转页面)