const url = window.location.href; const slug = url.substring(url.lastIndexOf('/') + 1); Post navigation componentdidmount called two times Redirect in react route v6