Can react-router4 block access to a route?

now there is a function that needs to determine the permission of the address of the route. If you do not have the permission, you will not enter the route.
saw this

in the react-router document.
const getConfirmation = (message, callback) => {
  const allowTransition = window.confirm(message)
  callback(allowTransition)
}

<BrowserRouter getUserConfirmation={getConfirmation}/>

but if you click cancel, you will still enter the route. is there any divine guidance?

Apr.13,2021

use the route guard hook to determine whether you have permission before entering the route, and return to the upper layer route or error page if not.

Menu