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,528
  • 3
  • 29
  • 34
Jon
  • 303
  • 3
  • 10
  • 25

1 Answers1

3

You can use substr to take string after / only

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

console.log(pathName)
Code Maniac
  • 35,187
  • 4
  • 31
  • 54