Skip to content

Commit fe24f8b

Browse files
committed
Revert "chore: base 0.32.x reconciler support (#28)"
This reverts commit 5ead4a6.
1 parent 2ace00f commit fe24f8b

7 files changed

Lines changed: 222 additions & 244 deletions

File tree

bun.lock

Lines changed: 197 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@
4343
"typecheck": "tsc --noEmit",
4444
"test:watch": "jest --watch",
4545
"validate": "bun run prettier && bun run lint && bun run typecheck && bun run test",
46-
"validate:fix": "bun run prettier:fix && bun run lint --fix && bun run typecheck && bun run test -u",
46+
"validate:write": "bun run prettier:write && bun run lint --fix && bun run typecheck && bun run test -u",
4747
"prettier": "prettier --check .",
48-
"prettier:fix": "prettier --write .",
48+
"prettier:write": "prettier --write .",
4949
"release": "release-it"
5050
},
5151
"dependencies": {
52-
"react-reconciler": "~0.32.0",
53-
"@types/react-reconciler": "~0.32.0"
52+
"react-reconciler": "~0.31.0",
53+
"@types/react-reconciler": "~0.31.0"
5454
},
5555
"peerDependencies": {
56-
"react": "^19.1.0"
56+
"react": "^19.0.0"
5757
},
5858
"devDependencies": {
5959
"@eslint/js": "^9.21.0",
@@ -65,7 +65,7 @@
6565
"eslint-plugin-simple-import-sort": "^12.1.1",
6666
"jest": "^30.2.0",
6767
"prettier": "^3.5.2",
68-
"react": "^19.1.0",
68+
"react": "^19.0.0",
6969
"release-it": "^18.1.2",
7070
"ts-jest": "^29.2.6",
7171
"tsup": "^8.4.0",

src/__tests__/activity.test.tsx

Lines changed: 0 additions & 141 deletions
This file was deleted.

src/constants.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ export const Tag = {
66

77
// Container should render as <>{...}</>
88
export const CONTAINER_TYPE = "";
9-
10-
// Source: https://github.com/facebook/react/blob/main/packages/shared/ReactSymbols.js#L16
11-
export const REACT_CONTEXT_TYPE: symbol = Symbol.for("react.context");

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { createRoot } from "./renderer";
22

3-
export type { Root, RootOptions } from "./renderer";
3+
export type { Root, RootOptions, ErrorHandler, ErrorInfo } from "./renderer";
44
export type { HostElement, HostElementProps, HostNode } from "./host-element";
55
export type { JsonElement, JsonNode } from "./render-to-json";
66
export type { QueryOptions } from "./query-all";

src/reconciler.ts

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import type { ReactElement } from "react";
2-
import type { Fiber, ReactContext, ReactProviderType } from "react-reconciler";
2+
import type { Fiber } from "react-reconciler";
33
import ReactReconciler from "react-reconciler";
44
import { DefaultEventPriority, NoEventPriority } from "react-reconciler/constants";
55

66
import { Tag } from "./constants";
7-
import { REACT_CONTEXT_TYPE } from "./constants";
87
import { formatComponentList } from "./utils";
98

109
export type Type = string;
@@ -44,13 +43,11 @@ export type TextInstance = {
4443

4544
export type SuspenseInstance = object;
4645
export type HydratableInstance = object;
47-
export type FormInstance = object;
4846
export type PublicInstance = object | TextInstance;
4947
export type UpdatePayload = unknown;
5048
export type ChildSet = unknown;
5149
export type TimeoutHandle = unknown;
5250
export type NoTimeout = unknown;
53-
export type TransitionStatus = unknown;
5451

5552
type HostContext = {
5653
type: string;
@@ -70,13 +67,12 @@ const hostConfig: ReactReconciler.HostConfig<
7067
TextInstance,
7168
SuspenseInstance,
7269
HydratableInstance,
73-
FormInstance,
7470
PublicInstance,
7571
HostContext,
72+
UpdatePayload,
7673
ChildSet,
7774
TimeoutHandle,
78-
NoTimeout,
79-
TransitionStatus
75+
NoTimeout
8076
> = {
8177
/**
8278
* The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
@@ -564,6 +560,8 @@ const hostConfig: ReactReconciler.HostConfig<
564560
* be aware that it may change significantly between versions. You're taking on additional maintenance risk by
565561
* reading from it, and giving up all guarantees if you write something to it.
566562
*/
563+
// @ts-expect-error @types/react-reconciler types don't fully match react-reconciler's actual Flow types.
564+
// Correctness is verified through tests.
567565
commitUpdate(
568566
instance: Instance,
569567
type: Type,
@@ -688,33 +686,11 @@ const hostConfig: ReactReconciler.HostConfig<
688686
// -------------------
689687
supportsHydration: false,
690688

691-
requestPostPaintCallback(_callback: (endTime: number) => void) {},
692-
693689
NotPendingTransition: null,
694690

695-
// Based on: https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactFiberConfigTestHost.js#L606
696-
HostTransitionContext: {
697-
$$typeof: REACT_CONTEXT_TYPE,
698-
Consumer: null as unknown as ReactContext<TransitionStatus>,
699-
Provider: null as unknown as ReactProviderType<TransitionStatus>,
700-
_currentValue: null,
701-
_currentValue2: null,
702-
_threadCount: 0,
703-
},
704-
705691
resetFormInstance(_form: Instance) {},
706692

707-
trackSchedulerEvent: function (): void {},
708-
709-
// Based on: https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactFiberConfigTestHost.js#L256
710-
resolveEventType: function (): null | string {
711-
return null;
712-
},
713-
714-
// Based on: https://github.com/facebook/react/blob/main/packages/react-test-renderer/src/ReactFiberConfigTestHost.js#L259
715-
resolveEventTimeStamp: function (): number {
716-
return -1.1;
717-
},
693+
requestPostPaintCallback(_callback: (endTime: number) => void) {},
718694
};
719695

720696
export const TestReconciler = ReactReconciler(hostConfig);

src/renderer.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import { TestReconciler } from "./reconciler";
1313

1414
const defaultCreateMockNode = () => ({});
1515

16-
const defaultOnUncaughtError = (error: unknown, errorInfo: BaseErrorInfo) => {
16+
const defaultOnUncaughtError = (error: unknown, errorInfo: ErrorInfo) => {
1717
console.error("Uncaught error:", error, errorInfo);
1818
};
19-
const defaultOnCaughtError = (error: unknown, errorInfo: BaseErrorInfo) => {
19+
const defaultOnCaughtError = (error: unknown, errorInfo: ErrorInfo) => {
2020
console.error("Caught error:", error, errorInfo);
2121
};
22-
const defaultOnRecoverableError = (error: unknown, errorInfo: BaseErrorInfo) => {
22+
const defaultOnRecoverableError = (error: unknown, errorInfo: ErrorInfo) => {
2323
console.error("Recoverable error:", error, errorInfo);
2424
};
2525

@@ -55,11 +55,13 @@ export type RootOptions = {
5555
isStrictMode?: boolean;
5656
};
5757

58-
type ErrorHandler = (error: unknown, errorInfo: BaseErrorInfo) => void;
58+
/** Callback for handling React errors. */
59+
export type ErrorHandler = (error: unknown, errorInfo: ErrorInfo) => void;
5960

60-
interface BaseErrorInfo {
61-
componentStack?: string;
62-
}
61+
/** Error information provided to error handlers. */
62+
export type ErrorInfo = {
63+
componentStack: string;
64+
};
6365

6466
/**
6567
* Root instance returned by createRoot. Provides methods to render and unmount components.
@@ -105,8 +107,10 @@ export function createRoot(options?: RootOptions): Root {
105107
options?.identifierPrefix ?? "",
106108
options?.onUncaughtError ?? defaultOnUncaughtError,
107109
options?.onCaughtError ?? defaultOnCaughtError,
110+
// @ts-expect-error @types/react-reconciler types don't include onRecoverableError parameter
111+
// in the createContainer signature, but react-reconciler's actual Flow types do.
112+
// Correctness is verified through tests.
108113
options?.onRecoverableError ?? defaultOnRecoverableError,
109-
() => {}, // onDefaultTransitionIndicator
110114
null, // transitionCallbacks
111115
);
112116

0 commit comments

Comments
 (0)