Skip to content
Advertisement

is there a way to nest routes in react

I was wondering if there is a way to nest routes in react in that Navbar is to become the parent component of dashboard and properties

JavaScript

Just like you would do in Vue router

JavaScript

Advertisement

Answer

Yes, create a layout route that renders the Navbar component and an Outlet for nested routes.

Example:

JavaScript

JavaScript

If you wanted to achieve the same thing using a routes config object:

JavaScript

JavaScript

Documentation:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement