fix(streamdown-rn): resolve React 19 runtime crash and type compatibility#23
Open
thedonmon wants to merge 3 commits intodarkresearch:mainfrom
Open
fix(streamdown-rn): resolve React 19 runtime crash and type compatibility#23thedonmon wants to merge 3 commits intodarkresearch:mainfrom
thedonmon wants to merge 3 commits intodarkresearch:mainfrom
Conversation
…tterns Add backslash escape awareness, underscore emphasis (_/__), math block tracking ($/$$), image handling (![]()), word-internal marker detection, and list marker awareness. 55 new tests covering all additions.
Replace React.FC<Props> with React.memo<Props> so the exported type is NamedExoticComponent instead of FC, avoiding cross-version @types/react ReactNode mismatch.
…ntime The dist/ was shipping raw JSX (jsx: preserve/react-native), relying on the consumer's bundler to transform it. With bun's symlinked node_modules, Metro could resolve react/jsx-runtime from a different path, causing the 'older version of React' runtime error. Compiling to react-jsx ensures the dist imports from react/jsx-runtime directly.
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 two bugs that prevent
streamdown-rnfrom working in Expo 54 consumer apps, plus improves the incomplete markdown handler.Bug 1: Runtime crash — "A React Element from an older version of React"
The
dist/files shipped raw JSX becausetsconfig.jsoninherited"jsx": "react-native"(equivalent to"preserve"). This works when the consumer's bundler resolvesreactfrom the project root, but with bun's symlinkednode_modules, Metro resolvesreact/jsx-runtimefrom inside.bun/streamdown-rn@0.2.1+.../instead of the project root — loading a different React copy at runtime.Fix: Set
"jsx": "react-jsx"inpackages/streamdown-rn/tsconfig.jsonso the compiled output imports{ jsx } from "react/jsx-runtime"directly, ensuring Metro resolves a single React instance.Bug 2: TypeScript error — "'StreamdownRN' cannot be used as a JSX component"
Consumer projects with
@types/react@~19.1.x(which Expo 54 installs) get a type error becauseReact.FCresolves to different return types across@types/reactminor versions. The exportedReact.FC<StreamdownRNProps>from19.0.xis incompatible with19.1.x's stricterReactNodedefinition.Fix: Change
export const StreamdownRN: React.FC<Props> = React.memo(...)toexport const StreamdownRN = React.memo<Props>(...). The emitted type becomesReact.NamedExoticComponent<Props>which is stable across@types/reactversions.Improvement: Align incomplete markdown handler with remend patterns
Ported several missing features from the upstream
remendpackage intocore/incomplete.ts:\*,\_,\~, etc.)hello_world,file*nameno longer trigger emphasis)_italic_,__bold__)$inline$,$$block$$) — skips emphasis inside math) — strips incomplete images, auto-closes in URL phase* itemnot treated as italic)Changes
packages/streamdown-rn/tsconfig.json—"jsx": "react-jsx"packages/streamdown-rn/src/StreamdownRN.tsx— removeReact.FCannotationpackages/streamdown-rn/src/core/types.ts— addinMathBlock/inInlineMathto statepackages/streamdown-rn/src/core/incomplete.ts— new features listed abovepackages/streamdown-rn/src/__tests__/incomplete.test.ts— 55 new testsAll 256 tests pass. Type check and build succeed.