Redirect after submit in React

后端 未结 1 1930
失恋的感觉
失恋的感觉 2021-01-06 06:44

I\'m trying to redirect the user after a submit button has been pressed in my react app, but redirect never happens. After submit button I\'m sending data via axios to an AP

1条回答
  •  生来不讨喜
    2021-01-06 07:27

    By assuming you are using react-router v4, you will want to use history object to navigate.

    import { withRouter } from 'react-router';
    ...
    
    handleSubmit = () => {
      ...
      this.props.history.push('/moneyform');
    }
    
    render() {
      return (
        
          
    ... ) } export default withRouter(confirmWithdraw);

    0 讨论(0)
提交回复
热议问题