The article Confirming Navigation explains how to use a browser confirmation box in your transition hook. Fine. But I want to use my own Dialog box. If I were to use the methods
Above is great except when user goes back in history. Something like the following should fix the problem:
if (!withinHook && nextLocation) { if (nextLocation.action=='POP') { router.goBack() } else { router.push(nextLocation) } }