'React-router v6 showing two routes at the same time

I have this code right here and i was following the react-router v6 example, but in the code below the routes is rendering two route(the <Dashboard/> and the Hello page on App start).

<Routes>
        <Route path='/' element={<div><Outlet/></div>}>
          <Route index element={<div>hello</div>}/>
          <Route path="dashboard" element={<Dashboard />} />
          <Route path="login" element={<Login />} />
        </Route>
      </Routes>

It works fine when i go to localhost/dashboard and localhost/login, but i want it to render the hello screen when it starts meaning at 'localhost/'. And why can't my code work?

Thank you in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source