Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

const root = document.getElementById('app') return null #120

Open
q8tywolf opened this issue Jun 4, 2023 · 1 comment
Open

const root = document.getElementById('app') return null #120

q8tywolf opened this issue Jun 4, 2023 · 1 comment

Comments

@q8tywolf
Copy link

q8tywolf commented Jun 4, 2023

Hello

I have a weird issue
routes
Route.get('/test', async ({ inertia }) => { Logger.debug('hit /test') return inertia.render('Test', { someData: 'hello' }, { title: "welcome to test " }) })
app.tsx
import { InertiaApp } from '@inertiajs/inertia-react'
import React from 'react'
import ReactDOM from 'react-dom'
import '../css/app.css'

// initial page object with props from server
const root = document.getElementById('app')

console.log(root)
const page = JSON.parse(root?.dataset.page as string)

// dynamically load specified page component from "resources/js/Pages/." dir
async function resolver(pageName) {
const module = await import(./Pages/${pageName})
return module.default
}

function App() {
return <InertiaApp initialPage={page} resolveComponent={resolver} initialComponent={''} />
}

ReactDOM.render(, root)

image
image

@q8tywolf
Copy link
Author

q8tywolf commented Jun 5, 2023

fixed when I put scripts below @interia

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="icon" type="image/png" href="/favicon.ico">

  @entryPointStyles('app')


  <title>{{ title }}</title>
</head>
<body>
  @inertia()
    @entryPointScripts('app')
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant