How to cancel a login and redirect to previous page when using React SDK?

Hi,

I’m using withAuthenticationRequired() to guard a page. Let’s say the component is <GuardedPage /> and url is ‘/guardedPage’. So whenever users clicked the link ‘/guardedPage’ without login, they will be redirected to Auth0’s login page immediately .

In this case, if the user don’t want to login or register and simply want to go back to previous page (the one where the link ‘/guardedPage’ is clicked), is there any way to achieve this? There is not ‘Cancel’ or ‘Go back’ button/link on the Auth0 login page, and if click the browser’s back button, it will go to ‘/guardedPage’, which results in a redirection to Auth0 login page again.

Thanks!