Cómo obtener URL actual con JavaScript o React

const currentURL = window.location.href // returns the absolute URL of a page

const pathname = window.location.pathname //returns the current url minus the domain name
Terrible Teira