Skip to content

Instantly share code, notes, and snippets.

@ac205
Created February 18, 2020 13:35
Show Gist options
  • Save ac205/5d775235a51fa5cf21942b167c1eddbc to your computer and use it in GitHub Desktop.
Save ac205/5d775235a51fa5cf21942b167c1eddbc to your computer and use it in GitHub Desktop.
React Router Example
const ReactTransactAdmin = ({ match }) => (
<div>
<AdminAppbar />
<AdminMenu />
<Route path={match.url} exact component={AdminPanel} />
<Route path={match.url + "/HeroImages"} component={HeroImages} />
<Route path={match.url + "/features"} component={Features} />
<Route path={match.url + "/salebar"} component={SaleBar} />
<Route path={match.url + "/categories"} component={Categories} />
<Route path={match.url + "/products"} component={Products} />
<Route path={match.url + "/add-product"} component={AddProduct} />
</div>
);
const ReactTransact = ({ match }) => (
<div>
<Navbar />
<Menubar />
<MobileMenu />
<Route path={match.url} exact component={Home} />
<Route
path={match.url + "product-details/:name"}
component={ProductDetail}
/>
<Route path={match.url + "cart"} component={Cart} />
<Route path={match.url + "contact"} component={Contact} />
<Route path={match.url + "about"} component={About} />
<Route path={match.url + "profile"} component={Profile} />
<Route path={match.url + "shop"} component={Shop} />
<Footer />
</div>
);
return (
<Router>
<Switch>
<Route path="/admin" component={ReactTransactAdmin} />
<Route path="/" component={ReactTransact} />
</Switch>
</Router>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment