I use History package to redirect invalid URL to 404 page on my react component.
I think you got the right idea.
I personnaly use
.replace when redirecting from an invalid url (or non relevant, i.e. redirect to "profile" page when a logged user goes to the "/login" url), so using the browser's "back" button works properly for the end user.