0

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 />} />
        ...
mrpbennett
  • 1,527
  • 15
  • 40

1 Answers1

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.