Skip to content

fix: render Streamdown on React 18 via useContext - #2

Draft
yzzting wants to merge 1 commit into
lobehub:mainfrom
yzzting:feat/react-18-usecontext
Draft

yzzting wants to merge 1 commit into
lobehub:mainfrom
yzzting:feat/react-18-usecontext

Conversation

@yzzting

@yzzting yzzting commented Sep 18, 2026

Copy link
Copy Markdown

Summary

@lobehub/streamdown@1.3.1 peers React 19 and calls use(Context) plus JSX <Context value> in StreamdownProfilerProvider. Apps still on React 18 fail at runtime with use is not a function even after an npm override.

This swaps use for useContext and renders Context.Provider. That is equivalent for this non-promise context, so React 19 keeps working, and React 18 can mount Streamdown / CachedMarkdown.

Peer range is >=18 so install no longer ERESOLVE on React 18.

Test plan

  • Existing profiler tests
  • New hook test that useStreamdownProfiler reads the profiler through useContext
  • pnpm test / pnpm type-check on this branch

Made with Cursor

The profiler called React 19 use() and treated Context as a JSX component, so Streamdown threw on React 18. useContext plus Context.Provider is equivalent for this non-promise context and keeps React 19 working.

Co-authored-by: Cursor <cursoragent@cursor.com>
@yzzting
yzzting marked this pull request as draft September 18, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant