Home > Mobile >  React router routes in route not working . When I type /signUp, I can't get anything on the pag
React router routes in route not working . When I type /signUp, I can't get anything on the pag

Time:06-09

When I type /signUp, I can't get anything on the page, I couldn't solve this problem, can you help me?

    <BrowserRouter>
  <Routes>
    <Route path="/" element={<Home />} />
    <Route  element={<AuthLayout />}>
  
        <Route path="signIn" element={<SignIn />} />
        <Route path="signUp" element={<SignUp />} />
      
    </Route>
  </Routes>
</BrowserRouter>

CodePudding user response:

I believe in your path you need a / in front path="/signIn"

CodePudding user response:

Why is AuthLayout wrapping SignIn, SignUp components?

Then AuthLayout page will be shown instead of SignIn page.

I think You should fix like this.

<BrowserRouter>
  <Routes>
    <Route path="/" element={<Home />} />
    <Route path="auth" element={<AuthLayout />} />
    <Route path="signIn" element={<SignIn />} />
    <Route path="signUp" element={<SignUp />} />
  </Routes>
</BrowserRouter>
  • Related