diff --git a/examples/01-hello/README.md b/examples/01-hello/README.md index 16bedc73..bebe1605 100644 --- a/examples/01-hello/README.md +++ b/examples/01-hello/README.md @@ -20,7 +20,7 @@ examples/01-hello/ ├── app.py # Express: set_react_page() + 2 reactive_output outputs ├── app-core.py # Core: page_react_html() + App(app_ui, server), same outputs └── www/ - ├── index.html # 3 lines: stylesheet, #root div, script + ├── index.html # 2 lines: stylesheet, script (the app appends its own mount div to
) ├── app.js # raw React.createElement (with `h` shorthand) └── main.css # body reset ``` diff --git a/examples/01-hello/www/app.js b/examples/01-hello/www/app.js index e44c79db..ed53ac7d 100644 --- a/examples/01-hello/www/app.js +++ b/examples/01-hello/www/app.js @@ -102,5 +102,9 @@ function App() { ); } -const root = ReactDOM.createRoot(document.getElementById("root")); +// No mount div in index.html — create the container and append it to . +// The script is deferred, so document.body is parsed by the time this runs. +const root = ReactDOM.createRoot( + document.body.appendChild(document.createElement("div")), +); root.render(h(App)); diff --git a/examples/01-hello/www/index.html b/examples/01-hello/www/index.html index 7a54efb1..880e7633 100644 --- a/examples/01-hello/www/index.html +++ b/examples/01-hello/www/index.html @@ -1,3 +1,2 @@ -