Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
React-Router open route when page loads

I want the first Route below (path="/tasks") to open when a user opens my page. Now when a user opens my page they don't see any of the components. What is the easiest way to achieve this?

<Routes>
  <Route path="/tasks" element={<AllTasks completeTask={completeTask} removeTask={removeTask} />} />
  <Route path="/upcoming" element={<UpcomingReminders completeTask={completeTask} removeTask={removeTask} />} />
  <Route path="/today" element={<TodaysReminders completeTask={completeTask} removeTask={removeTask} />} />
  <Route path="/form" element={<Form />} />
  <Route path="/missed" element={<MissedTasks removeTask={removeTask} completeTask={completeTask} />}></Route>
  <Route path="/recurring" element={<Recurring completeTask={completeTask} removeTask={removeTask} />}></Route>
  <Route path="/completed" element={<CompletedTasks removeCompletedTask={removeCompletedTask} />}></Route>
  <Route path="/about" element={<About />} />
</Routes>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need to use an array in path and don't forget the exact parameter

<Route path=["/", "/tasks"] exact element={<AllTasks completeTask={completeTask} removeTask={removeTask} />} />
about 4 years ago · Juan Pablo Isaza Report

0

If you want the "/tasks" route to be a sort of "default" route then render a redirect to that specific route.

Example:

<Routes>
  <Route index element={<Navigate to="/tasks" replace />} /> // redirect to default path
  <Route
    path="/tasks"
    element={<AllTasks completeTask={completeTask} removeTask={removeTask} />}
  />
  ...
</Routes>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!