let prevLocation; history.listen(nextLocation => { console.log(prevLocation); // ... prevLocation = nextLocation; });