How to pass params with history.push/Link/Redirect in react-router v4?

前端 未结 10 1190
你的背包
你的背包 2020-11-22 04:27

How can we pass parameter with this.props.history.push(\'/page\') in React-Router v4?

.then(response => {
       var r = this;
        if (re         


        
10条回答
  •  猫巷女王i
    2020-11-22 05:05

    It is not necessary to use withRouter. This works for me:

    In your parent page,

    
       
             (
              
            )} />
    
             (
              
              )} /> 
          
    
    

    Then in ComponentA or ComponentB you can access

    this.props.history

    object, including the this.props.history.push method.

提交回复
热议问题