Home > Enterprise >  How to render two components in a single route?
How to render two components in a single route?

Time:04-04

{/* i want to render Projects Component with Home Component in a single page. */}

  <Navbar />
  <Routes>
    <Route path='/' element={<Home/>}/> 
    <Route path='/Projects' element={<Projects/>}/>
    <Route path='/About' element={<About/>}/>
    <Route path='/MyStack' element={<MyStack/>}/>
    
    <Route path='/Blogs' element={<Blogs/>}/>
    <Route path='/Contact' element={<Contact/>}/>
  </Routes>
  
</div>

i don't have any extra button on navbar for projects. how to render project component in home component ?

CodePudding user response:

Try wrapping in React Fragments and rendering both:

 <Route path='/' element={<><Home/><Projects/></>}/> 
  • Related