Sha256: 74c92786983c117a5faecc49d317cf8309a4e8eae724fea84ee43f0b868f51d9
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
import { createInertiaApp } from '@inertiajs/react' import { createElement, ReactNode } from 'react' import { createRoot } from 'react-dom/client' // Temporary type definition, until @inertiajs/react provides one type ResolvedComponent = { default: ReactNode layout?: (page: ReactNode) => ReactNode } createInertiaApp({ // Set default page title // see https://inertia-rails.netlify.app/guide/title-and-meta // // title: title => title ? `${title} - App` : 'App', // Disable progress bar // // see https://inertia-rails.netlify.app/guide/progress-indicators // progress: false, resolve: (name) => { const pages = import.meta.glob<ResolvedComponent>('../pages/**/*.tsx', { eager: true, }) const page = pages[`../pages/${name}.tsx`] if (!page) { console.error(`Missing Inertia page component: '${name}.tsx'`) } // To use a default layout, import the Layout component // and use the following line. // see https://inertia-rails.netlify.app/guide/pages#default-layouts // // page.default.layout ||= (page) => createElement(Layout, null, page) return page }, setup({ el, App, props }) { if (el) { createRoot(el).render(createElement(App, props)) } else { console.error( 'Missing root element.\n\n' + 'If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n' + 'Consider moving <%%= vite_typescript_tag "inertia" %> to the Inertia-specific layout instead.', ) } }, })
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inertia_rails-3.5.0 | lib/generators/inertia/install/templates/react/inertia.ts |