0

I have created a component where I am getting Route name through window.location.pathname it is working fine and gives me a route name but I want to remove forward slash / from route name . I am beginner to ReactJS , Could someone please help me how to solve this problem ?

const pathName=window.location.pathname;
worc
  • 3,654
  • 3
  • 31
  • 35
Jon
  • 293
  • 3
  • 11
  • 29

1 Answers1

3

You can use substr to take string after / only

const pathName= window.location.pathname.substr(1,)

console.log(pathName)
Code Maniac
  • 37,143
  • 5
  • 39
  • 60