score:-1

Remove 'exact' from your routes props.

score:1

You can simply use the useHistory hook from react-router-dom

import { useHistory } from "react-router-dom";

const history = useHistory();

...

<div onClick={ ()=>history.goBack() }>Back </div>

score:8

You can achieve this by calling goBack() function in history object inside withRouter().

import React from 'react';
import { withRouter } from 'react-router-dom'

export default withRouter(({ history }) => {
  return (
    <div>
      <button onClick={() => history.goBack()}>BACK</button>
    </div>
  )
});

Related Query

More Query from same tag