An AI response arrives as text deltas. A Markdown renderer normally receives a document. Connecting them with render(allTextSoFar) repeatedly asks the renderer to interpret text the reader has already seen.
I built react-stream-markdown to explore a different boundary: keep completed blocks on screen and re-parse the unfinished suffix. The repository is currently version 0.4.1 and MIT licensed. Here is how it works, where its cost still grows, and what the published benchmark actually measures.
Where repeated work comes from
Suppose a response contains N characters and arrives in chunks of c characters. A full-document parser sees c characters, then 2c, then 3c, and so on. With a linear parser, the sum of characters examined is approximately N²/(2c). This models repeated parsing work; it does not mean every part of browser rendering is quadratic.
React can reuse DOM elements after reconciliation. That does not automatically prevent an upstream Markdown parser from scanning the accumulated string.…