Skip to content

Commit

Permalink
Merge branch 'craigspaeth-pass-uncaught-err-handler-to-react-reconciler'
Browse files Browse the repository at this point in the history
  • Loading branch information
lavrton committed Aug 12, 2024
2 parents b1698a1 + 672dafb commit 9613a7e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"url": "[email protected]:konvajs/react-konva.git"
},
"dependencies": {
"@types/react-reconciler": "^0.28.2",
"@types/react-reconciler": "^0.28.8",
"its-fine": "^1.2.5",
"react-reconciler": "0.31.0-beta-73bcdfbae5-20240502",
"scheduler": "0.25.0-beta-73bcdfbae5-20240502"
Expand Down Expand Up @@ -45,20 +45,20 @@
"react-dom": ">=19.0.0-beta"
},
"devDependencies": {
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@types/react": "18.2.8",
"@types/chai": "^4.3.17",
"@types/mocha": "^10.0.7",
"@types/react": "18.3.3",
"chai": "4.3.7",
"konva": "^9.1.0",
"konva": "^9.3.14",
"mocha-headless-chrome": "^4.0.0",
"parcel": "^2.9.1",
"parcel": "^2.12.0",
"process": "^0.11.10",
"react": "19.0.0-beta-73bcdfbae5-20240502",
"react-dom": "19.0.0-beta-73bcdfbae5-20240502",
"sinon": "^15.1.0",
"timers-browserify": "^2.0.12",
"typescript": "^5.1.3",
"use-image": "^1.1.0",
"use-image": "^1.1.1",
"util": "^0.12.5"
},
"scripts": {
Expand Down
42 changes: 37 additions & 5 deletions src/ReactKonvaCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,37 @@

import React from 'react';
import Konva from 'konva/lib/Core.js';
import ReactFiberReconciler from 'react-reconciler';
import ReactFiberReconciler, {
RootTag,
SuspenseHydrationCallbacks,
TransitionTracingCallbacks,
} from 'react-reconciler';
import { LegacyRoot } from 'react-reconciler/constants.js';
import * as HostConfig from './ReactKonvaHostConfig.js';
import { applyNodeProps, toggleStrictMode } from './makeUpdates.js';
import { useContextBridge, FiberProvider } from 'its-fine';
import { Container } from 'konva/lib/Container.js';

/**
* React 19 introduced a new `ReactFiberReconciler.createContainer` signature
* with more error handling options [1]. The DefinitelyTyped types are also
* out of date because of this [2].
*
* 1. https://github.com/facebook/react/commit/a0537160771bafae90c6fd3154eeead2f2c903e7
* 2. https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-reconciler/index.d.ts#L920
*/
type NewCreateContainer = (
containerInfo: Container,
tag: RootTag,
hydrationCallbacks: null | SuspenseHydrationCallbacks<any>,
isStrictMode: boolean,
concurrentUpdatesByDefaultOverride: null | boolean,
identifierPrefix: string,
onUncaughtError: (error: Error) => void,
onCaughtError: (error: Error) => void,
onRecoverableError: (error: Error) => void,
transitionCallbacks: null | TransitionTracingCallbacks
) => ReactFiberReconciler.FiberRoot;

function usePrevious(value) {
const ref = React.useRef({});
Expand Down Expand Up @@ -61,12 +87,18 @@ const StageWrap = (props) => {

_setRef(stage.current);

// @ts-ignore
fiberRef.current = KonvaRenderer.createContainer(
// @ts-ignore
fiberRef.current = (KonvaRenderer.createContainer as NewCreateContainer)(
stage.current,
LegacyRoot,
false,
null
null,
null,
undefined,
undefined,
console.error,
console.error,
console.error,
null,
);
KonvaRenderer.updateContainer(
React.createElement(Bridge, {}, props.children),
Expand Down

0 comments on commit 9613a7e

Please sign in to comment.