Skip to content

withLayout high-order-component

Use the withLayout high-order component to help with type-hinted Persistent Layouts.

Type Signature & Types
typescript
interface DefaultLayoutProps {
  title?: string
}

interface LayoutProps extends PropsWithChildren<DefaultLayoutProps> {}

type WithLayout = (
  layout: ComponentType<Expand<Omit<LayoutProps, "children">>>,
  props?: ComponentPropsWithoutRef<typeof layout>
) => (page: ReactElement) => ReactNode

declare const withLayout: WithLayout

Usage

tsx
import { withLayout } from '@inertiajs-revamped/react'

function BlogPage() {
  return <div>Blog Page</div>
}

BlogPage.layout = withLayout(Layout, {
  title: 'Blog Page',
  // ...extra type-hinted props
})

export default BlogPage