Repository navigation
Conversation
The directive rendered with ReactDom.render, deprecated in React 18 and removed in 19, so on a current React it raised "react_dom.render is not a function" and rendered nothing. It now creates a root through react-dom/client and renders into that. The root is kept per element: one root for the element lit is rendering into, unmounted when lit hands the directive a different element and when the directive disconnects. Fable.React binds only the old react-dom entry point, so the two members of react-dom/client this needs are declared in the file. react and react-dom move to 19 in the repo, since the sample renders a React component through this directive. The docs toolchain (nacara, gatsby 3) pins react 16/17 as a peer, so package.json overrides react and react-dom to the repo's own versions rather than letting npm refuse. npm test cannot load React (it ships CommonJS and reads process.env at import time), so test/react-check is a page that renders a component through the directive, renders it again with new props and leaves the result on window.__result. Run it with npm run check:react. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
npm 11 prunes optional peers that npm 10's `npm ci` still expects, so the lock from the previous commit failed CI with "Missing: type-fest@0.13.1". Regenerated with npm 10.9.9 on Node 22, which is what test.yml runs; npm 11 accepts it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
React.toLitrenders withReactDom.render, which React 18 deprecated and React 19 removed. On React 19 the directive raises and renders nothing:This switches it to
createRootfromreact-dom/client.What changes
src/Lit.React/Lit.React.fs: the directive keeps one root per element. A new root is created only when lit hands the directive a different element, and the old one is unmounted then. The root is also unmounted when the directive disconnects. Fable.React 9.4.0 binds only the oldreact-domentry point, so the two members ofreact-dom/clientthis needs (createRoot, and a root'srender/unmount) are declared in the file.package.json:reactandreact-domgo to^19, because the sample renders a Feliz component through this directive. The docs toolchain (nacara, gatsby 3) declares react 16/17 as a peer, so npm refuses the install outright. Anoverridesentry points react and react-dom at the repo's own versions. The lock file changes only for that (under 100 lines, written with npm 10 as CI uses).test/react-check/: a manual check page, run withnpm run check:react.npm testcan't load React: it ships CommonJS and readsprocess.envat import time, and the test runner serves ES modules to a browser that has neither. The page renders a component through the directive, renders it again with new props, and leaves the result onwindow.__result.Requires React 18 or newer. Apps still on React 17 should stay on the current Fable.Lit.React.
How I checked it
dotnet build Fable.Lit.slnandnpm test(37 passed), the same steps astest.yml.npm run check:reacton React 19.3.1: the page renders "one", then "two" after new props, with no errors. With the oldLit.React.fsthe same page throws theTypeErrorabove.sample/App.fs) on React 19.3.1: the React card renders, itsuseStatecounts clicks, hiding it runs its effect cleanup, and showing it again mounts a fresh one.Not covered
npm run docsdoesn't work onmaintoday on current Node: on Node 25 nacara passes an option tormdirthat Node removed, and on Node 22 it fails looking forbuild/docs. With this change it also fails onimport "react-dom/server.js", which React 19 doesn't export. Nothing in CI builds the docs, so this PR doesn't break a working pipeline. Whoever revives the docs will still need to replace or patch nacara for React 19.ReactDom.render, and fixing it is a bigger change than this.🤖 Generated with Claude Code