How to back from Component in react redux

2019-07-29 12:17发布

问题:

i have a Car page, includes one edit and add components, it's working fine when i dispatch with button now i am trying to back from the component using button, i tried history.goBack but its going to home page

Home page localhost:8080/

Issue page localhost:8080/car/5c7a29418c57f7069f382491

above page, i have <CarAdd> and <CarEdit> includes, dispatch using below button

 <button  type="button"  onClick={() => 
     this.props.dispatch({ type: 'ADD_NEW_CAR'})}>
                   Add Car
 </button>

then Add car shows, i used editing: true and enable this component, component have car add form, then how can i BACK using button

   <button onClick={history.goBack}>Back</button>

// going to Home page not localhost:8080/car/:id


  <Link to="/car/5c7a29418c57f7069f382491">Back</Link>

// not working