Skip to content

fix(ai-components): use simple-markdown 0.7.3 to stop npm nesting React 18 under core - #3989

Merged
isekovanic merged 1 commit into
v9-releasefrom
fix/simple-markdown-react-19-npm-v9
Nov 12, 2026
Merged

isekovanic merged 1 commit into
v9-releasefrom
fix/simple-markdown-react-19-npm-v9

Conversation

@isekovanic

Copy link
Copy Markdown
Contributor

Ticket: https://linear.app/stream/issue/RN-485

🎯 Goal

Fix a startup crash for integrators who install with npm on React 19: "Cannot read property 'useState' of null".

Since 9.10.0, core depends on @khanacademy/simple-markdown (^2.1.0) for the AI components' markdown. That package peer-depends on react/react-dom ^18.2.0. Core does not declare react itself, so npm satisfies the peer by nesting React 18.3.1 at node_modules/stream-chat-react-native-core/node_modules/react. Core's own import 'react' then resolves to that copy, and the app runs two Reacts.

Only npm does this. Yarn 1, Yarn 4, pnpm 10 and bun 1.3 all hand core the app's React 19, which is why the monorepo never showed it.

🛠 Implementation details

Replace @khanacademy/simple-markdown with the original simple-markdown ^0.7.3. The fork was cut from it at 0.8.0, and 0.7.3 has no peer dependencies. It is already in the tree through react-native-markdown-package, and core's main entry already imported it (renderText.tsx) without declaring it.

  • package/package.json / yarn.lock: swap the dependency (the fork and @khanacademy/perseus-utils drop out).
  • src/ai-components/markdown/*: import from simple-markdown. The API and type names are the same.
  • bin/validate-entry-isolation.js: drop the fork from the AI-only packages list, since the main entry already uses simple-markdown.
  • src/ai-components/README.md: point the rules link at the original repo.

The fork's newer releases don't help. Every version up to 4.0.3, and Perseus main, still declares react/react-dom ^18.2.0. 4.x is also ESM-only, so Metro on RN 0.76–0.78, which v9 still supports, can't resolve it.

🎨 UI Changes

None. Markdown output is identical.

🧪 Testing

  • yarn lint, cd package && yarn test:typecheck, yarn build and yarn test:unit (220 suites, 2421 tests) all pass.
  • npm proof: npm install --package-lock-only next to react@19.3.0. Published 9.14.1 nests react/react-dom 18.3.1 under core; the packed fix resolves a single React 19.3.0, with no @khanacademy packages.
  • Parity between the fork (2.2.3) and 0.7.3, run through our AI markdown rules on 2,732 markdown files: the parse trees and rendered element trees are identical. A source diff confirms the parser and regex code is the same. The only differences are sanitizeUrl and the default hr output, and both are code we never run.
  • On device: checked on the V10 PR, fix(ai-components): use simple-markdown 0.7.3 to stop npm nesting React 18 under core #3988. The markdown code differs slightly on v9, so the 2,732-file parity check was re-run here too, with identical results.

☑️ Checklist

  • I have signed the Stream CLA (required)
  • PR targets the v9-release branch
  • Documentation is updated
  • New code is tested in main example apps, including all possible scenarios
    • SampleApp iOS and Android
    • Expo iOS and Android

…ct 18 under core

@khanacademy/simple-markdown peer-depends on react/react-dom ^18.2.0. In a
React 19 app installed with npm, npm satisfies that peer by nesting React
18.3.1 under stream-chat-react-native-core, so core imports a second React and
the app crashes at startup ("Cannot read property 'useState' of null").

Switch to the original simple-markdown 0.7.3, which the fork was cut from and
which has no peer dependencies. It is already in the tree through
react-native-markdown-package. Parsing and rendering are identical.
@isekovanic isekovanic changed the title fix(ai-components): use simple-markdown 0.7.3 to stop npm nesting React 18 under core (v9) fix(ai-components): use simple-markdown 0.7.3 to stop npm nesting React 18 under core Nov 12, 2026
@isekovanic
isekovanic requested a review from oliverlaz November 12, 2026 20:25
@Stream-SDK-Bot

Copy link
Copy Markdown
Contributor

SDK Size

title develop branch diff status
js_bundle_size 2033 KB 2047 KB +14263 B 🔴
ai_components_size 344 KB 342 KB -2690 B 🚀
a2ui_size 103 KB 103 KB -299 B 🚀

@isekovanic
isekovanic merged commit 78c1dec into v9-release Nov 12, 2026
8 of 9 checks passed
@isekovanic
isekovanic deleted the fix/simple-markdown-react-19-npm-v9 branch November 12, 2026 20:44
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.

2 participants