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

156
Views
How to open a child route from a parent route by default - react-router-v6

I have tried to look through some docs for this one but can't seem to find what I'm looking for. I have some routes below.

I want to do the following: I want to be able to click on to the dotfile route but have the aliase route open as default.

The app is similar to this:

link - link -> page
link - link -> page
link - link

If that helps....I want the first page to be open when the 2nd link is clicked in the 2nd row. I am not sure if I am explaining it correctly.

My current routes are below these work as intended, I am just struggling to figure out how to open a child route initially

 <Routes>
      <Route path="/" element={<App />} />
      <Route path="dotfiles" element={<Dotfiles />}>
        <Route path="aliases" element={<Aliases />} /> // open when dotfiles is clicked
        <Route path="variables" element={<Variables />} />
        ...
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe you should be able to use history.push(url).

Sol 1: This is a react package you should be able to use to navigate between web pages. I would do it in the componentDidMount of Dotfiles.js. This would make it so that you navigate to aliases.js when you load into dotfiles.js.

Use this to install history: npm i history https://www.npmjs.com/package/history

Sol 2: (I am not sure if this will work for sure in your case) you can import Aliases in to dotfiles and render Aliases in dotfiles. This is the better solution in my opinion but I'm not sure if it applies in your case.

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!