Skip to content

Instantly share code, notes, and snippets.

@jrson83
Created March 9, 2023 21:58
Show Gist options
  • Save jrson83/822b6fea1329287376a52b887bc16394 to your computer and use it in GitHub Desktop.
Save jrson83/822b6fea1329287376a52b887bc16394 to your computer and use it in GitHub Desktop.
persistent layouts
import Layout from '../Layouts'
import { Fragment } from 'react'
const Home: React.FC = () => {
return (
<Fragment>
<h1>Home</h1>
<p>Hello, welcome to your first Inertia app!</p>
</Fragment>
)
}
// Property 'layout' does not exist on type 'FC<{}>'.ts(2339)
// |
// |
// | (parameter) page: any - Parameter 'page' implicitly has an 'any' type.ts(7006)
// | |
Home.layout = (page) => <Layout title="Home">{page}</Layout>
export default Home
import { Link } from '@inertiajs/react'
const Layout: React.FC<{ title?: string; children?: React.ReactNode }> = ({
children,
}) => {
return (
<main>
<header>
<Link href="/">Home</Link>
<Link href="/about">About</Link>
<Link href="/contact">Contact</Link>
</header>
<article>{children}</article>
</main>
)
}
export default Layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment