alexa

Router Navigate pathing system in ReactJS

Router Navigate pathing system in ReactJS

How do I make an increment so every question just adds ++ How do I go from questionaire/5 into questionaire/2 using navigate?

navigate("questionare/2") - leads me into /questionaire/1/questionaire/2

You can do this using an absolute path (e.g: '/questionaire/2') or a relative path (e.g: '2'), you can either do this using a Link or programmatically using a useNavigate hook.

 const navigate = useNavigate()
const handleClick = () => {
   navigate('2')
   //or
  navigate('/questionaire/2')
} 

Your current code is using a relative path plus and adding entire path, which leads to duplicated path as you mentioned.


266 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online

Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry