Repository navigation
fix: depend on remendConfig content instead of its identity - #30
Merged
eszlamczyk merged 2 commits intoAug 20, 2026
Merged
Conversation
useStreamdownMarkdown depended on options?.remendConfig by object
identity, and StreamdownText forwards the caller's remendConfig into a
fresh options literal every render. A consumer passing the documented
prop inline (remendConfig={{ katex: true }}) therefore re-ran the effect
on every commit: each run called setIsStreaming(true), bumped
versionRef, and scheduled another whole-document remend worklet job.
The version guard discarded stale results, so nothing rendered wrong —
the cost was unbounded re-scheduling, defeating the library's headline
feature of keeping the JS thread free.
Depend on a serialization of the config instead. An unchanged config now
produces a stable key, so idle re-renders stop rescheduling; a config
whose content actually changes still re-runs.
Regression test: renders the hook with an inline config literal, asserts
idle re-renders do not reschedule and a markdown change does. Fails on
the old dependency (3 calls instead of 1).
Xuepoo
force-pushed
the
fix/remendConfig-effect-rerun
branch
from
August 7, 2026 11:54
25b46db to
1f57059
Compare
eszlamczyk
approved these changes
Aug 20, 2026
eszlamczyk
left a comment
Collaborator
There was a problem hiding this comment.
Hi @Xuepoo The changes look sound, and the test is great inclusion. Everything LGTM, we will soonish release this along side some deps bump (like for example enriched-markdown bump to 1.0.0 for new features)
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.
Summary
Fixes #29 —
useStreamdownMarkdownnow depends on the content ofremendConfigrather than its object identity, so an inline config literal (the documented usage) no longer re-runs the effect — and reschedules the whole-document worklet job — on every render.Changes
src/hooks/useStreamdownMarkdown.ts: extractremendConfigKey = JSON.stringify(options?.remendConfig)and depend on it. Idle re-renders with an unchanged config stop rescheduling; a config whose content actually changed still re-runs. The effect intentionally reads the liveoptions?.remendConfig(with a comment explaining the deliberateexhaustive-depsdeviation).src/__tests__/useStreamdownMarkdown.test.tsx: regression test rendering the hook with an inline config literal, asserting idle re-renders do not reschedule and a markdown change does. Fails on the old code (3 worklet calls after 2 idle re-renders, expected 1) and passes with the fix.package.json: addreact-test-renderer+@types/react-test-rendererdevDependencies (the only test in the repo wasit.todo).Verification
jest: new test passes (1/1).tsc --noEmit: clean.eslint: clean on both changed files.StreamdownTextsources withreact-dom, worklet layer stubbed): inline config scheduled 4 jobs across 3 idle re-renders before the fix, 1 after; stable config was 1 in both.