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
children?: ComponentChildren
}
interface LayoutProps extends DefaultLayoutProps {}
type WithLayout = (
layout: ComponentType<Expand<Omit<LayoutProps, "children">>>,
props?: ComponentProps<typeof layout>
) => (page: VNode) => ComponentChildren
declare const withLayout: WithLayout
Usage
tsx
import { withLayout } from '@inertiajs-revamped/preact'
function BlogPage() {
return <div>Blog Page</div>
}
BlogPage.layout = withLayout(Layout, {
title: 'Blog Page',
// ...extra type-hinted props
})
export default BlogPage