Not giving Content when using React-Router-Dom

14 views Asked by At

In this code I have navigated Email.js to Password.js.it is working properly but when after it navigated to Password.js I have navigate to Country.js but it is not showing anything because the path which I have given is /country but it take /Password/Country and when in path I am giving /Password/Country then it is redirecting to /Password/Password/Country.

  <Routes>
    <Route exact path="/" element={ <Email/> }/>
    <Route exact path="Password" element={ <Password/>}/>
    <Route exact path="Type" element={ <Type/> }/>
    <Route exact path="/Country" element={ <Country/> }/>
  </Routes>
1

There are 1 answers

0
Mohamed Elgazar On

You need to use a relative path, like so:

<Routes>
    <Route exact path="/" element={ <Email/> }/>
    <Route exact path="Password" element={ <Password/>}/>
    <Route exact path="Type" element={ <Type/> }/>
    <Route exact path="Country" element={ <Country/> }/>
  </Routes>