From 5db554de35649298de05fc5526f4db92098eff27 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Wed, 19 Aug 2026 16:40:13 -0400 Subject: [PATCH] refactor(examples): mount 01-hello by appending to - Drop the #root div from index.html; app.js creates and appends its own mount container (script is deferred, so is parsed) - Prepares 01-hello for the page_react() mode where the server emits no body HTML at all --- examples/01-hello/README.md | 2 +- examples/01-hello/www/app.js | 6 +++++- examples/01-hello/www/index.html | 1 - 3 files changed, 6 insertions(+), 3 deletions(-) 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 @@ -