1

Hello I have the following logic, my routers wrapped with div`s

 render() {
    return (<div id={'container'} className={this.state.mode} >


                <div id='buyers'>
                   <NavBar />
                    <Route path='/buy/' render={()=><BuyersBuy />} /> 
                    <Route path='/refund/:id?' render={()=><BuyersRefund />} />
                    <Route path='/download/:id?' render={()=><BuyersDownload />} />
                    ...(Around 18 Routes for Buyers)
                </div>

                //Sellers Routers
                 <div id='dashboard'>
                    {this.state.pathname === '/private' && <TopNavBarSellers />}
                    {this.state.pathname === '/private' && <LeftNavBarSellers />}
                    <Route path='/dashbaord/profile' render={()=><SellersDash />} /> 
                    (4 routers more)
                </div>

And so according to that I wanted to create not found page

I tried to wrap a Switch but it doesn't work because there are div`s inside of it.

DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
Jennifer
  • 603
  • 1
  • 7
  • 17
  • Where is/are the nested `Router`(s)? Or do you simply mean your `Route`s are nested more deeply and because of this a single `Switch` won't work? Are you trying declare/use one 404 route, or are more than one acceptable? Do your `buyers` or `dashboard` ids need to wrap where they are? – Drew Reese Mar 14 '21 at 07:11
  • When would you show 404 page. Is it when none of the Buyer or Seller Routes match? – Shubham Khatri Mar 14 '21 at 07:18

1 Answers1

0

You can create a wrapper container to render passed children props inside div. For details check this gist

And to add 404-Not found, this SO post might help.

DevLoverUmar
  • 11,809
  • 11
  • 68
  • 98
  • There's a typo in that gist. `Container` attempts to destructure a `props` prop from the `props` object. I don't know if that is your gist, but you should test code before you suggest others to use it. Also, if your answer is mostly a link to another SO question/answer then perhaps it would be better to flag this one as a duplicate. – Drew Reese Mar 14 '21 at 07:24
  • Ok Thanks. No, that gist is not mine. – DevLoverUmar Mar 14 '21 at 07:26
  • 1
    @DevLoverUmar Thanks for your answer, but that didn't help – Jennifer Mar 16 '21 at 00:27