Here is how to use history.push() in React Router 5 in order to redirect a user to another page when they click a button for example:

import {useHistory} from 'react-router';

const MyComponent = () => {
const history = useHistory();

const redirectUser = () => {
    history.push('/newpage');
 }


 <button onClick={() => redirectUser()}>Redirect User</button>
};

export default MyComponent;