Skip to content

Commit

Permalink
Throw error when auto-tracking with React 19
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jun 25, 2024
1 parent 9f999b9 commit 600eb30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-rockets-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@preact/signals-react": patch
---

Throw an error when auto-tracking is used with React 19
7 changes: 7 additions & 0 deletions packages/react/runtime/src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
// @ts-ignore-next-line
// eslint-disable-next-line @typescript-eslint/no-unused-vars
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as ReactInternals,
version as reactVersion,
} from "react";
import React from "react";
import jsxRuntime from "react/jsx-runtime";
Expand Down Expand Up @@ -378,6 +379,12 @@ export function installJSXHooks() {
}

export function installAutoSignalTracking() {
const [major] = reactVersion.split(".").map(Number);
if (major >= 19) {
throw new Error(
"Automatic signals tracking is not supported in React 19 and later, try the Babel plugin instead https://github.com/preactjs/signals/tree/main/packages/react-transform#signals-react-transform."
);
}
installCurrentDispatcherHook();
installJSXHooks();
}

0 comments on commit 600eb30

Please sign in to comment.