refactor(examples): mount 01-hello by appending to <body> - #206
Closed
schloerke wants to merge 1 commit into
Closed
Conversation
- Drop the #root div from index.html; app.js creates and appends its own mount container (script is deferred, so <body> is parsed) - Prepares 01-hello for the page_react() mode where the server emits no body HTML at all
schloerke
added a commit
that referenced
this pull request
Aug 19, 2026
Carries #206's change forward onto the rewritten example. www/index.html is now two lines (stylesheet + deferred script) and app.js creates its own mount container via document.body.appendChild(document.createElement("div")) — safe because the script is deferred, so <body> is parsed when it runs. This prepares 01-hello for the upcoming page_react() page mode, where the server emits no body HTML at all and the client owns its mount point.
Collaborator
Author
|
Superseded by #207, which rebuilds Both PRs rewrite the same three files, so keeping them separate would only produce conflicts. Closing this one; the mount change lives in #207's second commit ( Note this was stacked on #198 (base |
schloerke
added a commit
that referenced
this pull request
Aug 19, 2026
* docs(01-hello): rebuild example as Shiny's Old Faithful 01_hello
Replaces the name/counter latency demo with Shiny's canonical 01_hello app —
a bins slider over the Old Faithful waiting times — rebuilt ui.tsx-first.
The server never renders a picture. One reactive_output returns histogram
{breaks, counts} as plain JSON plus a caption; www/app.js reads it with
useShinyOutputValue and draws the bars as SVG rects. That contrast with
traditional Shiny's renderPlot({ hist(...) }) is the point of the example.
- faithful.py: waiting times + a stdlib-only binner shared by app.py and
app-core.py, so the Python side stays dependency-free (no numpy/matplotlib)
- faithful.csv: base R's `faithful` exported for the Python servers; app.R
uses the built-in dataset and hist(..., plot = FALSE)
- app.R wraps the histogram vectors in I() so bins = 1 serializes as a JSON
array rather than a scalar, and returns NULL until the client's first bins
message arrives (Python raises a silent exception instead)
- The chart stays mounted while the server recomputes and only dims via
useShinyOutputStatus, per the repo's flicker guidance
Verified in a browser against app.py, app-core.py, and app.R: R and Python
produce identical counts at bins 1/2/7/30/50, and the console is clean.
* refactor(examples): mount 01-hello by appending to <body>
Carries #206's change forward onto the rewritten example. www/index.html is
now two lines (stylesheet + deferred script) and app.js creates its own mount
container via document.body.appendChild(document.createElement("div")) —
safe because the script is deferred, so <body> is parsed when it runs.
This prepares 01-hello for the upcoming page_react() page mode, where the
server emits no body HTML at all and the client owns its mount point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #198 (base
schloerke/npm-distribution).Summary
examples/01-hellono longer ships a#rootdiv.www/index.htmlis now two lines (stylesheet + deferred script) andapp.jscreates its own mount container withdocument.body.appendChild(document.createElement("div"))— safe because the script is deferred, so<body>is fully parsed when it runs.This prepares 01-hello for the upcoming
page_react()page mode, where the server emits no body HTML at all and the client owns its mount point.Verification
Ran the app and drove it in a browser: no
#rootelement in the DOM, the mount container hangs directly off<body>, typing a name updates both cards, and clicking brings client and server cards to the same count. (Note when trying it locally:www/app.jsis served statically with no cache busting, so a hard refresh is needed after pulling this change.)