Redirect after submit in React

后端 未结 1 1931
失恋的感觉
失恋的感觉 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 (
        <ReactFragment>
          <div>
          ...
        </ReactFragment>
      )
    }
    
    
    export default withRouter(confirmWithdraw);
    
    0 讨论(0)
提交回复
热议问题