Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/01-hello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <body>)
├── app.js # raw React.createElement (with `h` shorthand)
└── main.css # body reset
```
Expand Down
6 changes: 5 additions & 1 deletion examples/01-hello/www/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <body>.
// 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));
1 change: 0 additions & 1 deletion examples/01-hello/www/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<link rel="stylesheet" href="main.css" />
<div id="root"></div>
<script src="app.js" defer></script>
Loading