type RestoreHistoryFunction = ( ) => void ; export default function replaceHistoryLocation ( location ) { const previousState = window . history . state ; const previousLocation = location . toString ( ) ; window . history . replaceState ( previousState , document . title , location ) ; return ( ) => window . history . replaceState ( previousState , document . title , previousLocation ) ; }