Skip to content

Instantly share code, notes, and snippets.

View react-router-nested-routes-simple.jsx
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
// Layout
const Layout = ({ children }) => (
<div>
<header>My header</header>
{children}
<header>My footer</header>
</div>
View react-router-nested-routes.jsx
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
// Layout
const BackendLayout = ({ children }) => (
<div>
<header>This is the admin backend!</header>
<section>{children}</section>
</div>
);
View react-router-hoc-layout.jsx
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
// Layout
const Layout = ({ children }) => (
<div>
<header>My header</header>
{children}
<header>My footer</header>
</div>
View react-router-render-prop-layout.jsx
import React from "react";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
// Layout
const Layout = ({ children }) => (
<div>
<header>My header</header>
{children}
<header>My footer</header>
</div>