score:0

Accepted answer
export class ParentComponent extends React.Component {
    constructor(props) {
        super(props);
        this.location = this.props.location.pathname;
    }

    render() {
      return (
          {contentId && <MyChildComponent content={contentId} goBack={() => 
          history.push(this.location)} />}
      )
    }

score:1

constructor(props){
   super(props);
   this.goBack = this.goBack.bind(this);
}

goBack(){
    this.props.history.goBack(); // You're not calling it from history
}

.....

<button onClick={this.goBack}>Go Back</button>

Related Query

More Query from same tag