Skip to content

Commit 8f006b2

Browse files
committed
Get hello world working
1 parent 55965b7 commit 8f006b2

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

src/ink.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,29 @@ export default class Ink {
7777
// so that it's rerendered every time, not just new static parts, like in non-debug mode
7878
this.fullStaticOutput = '';
7979

80+
const rootTag = 1;
81+
const hydrationCallbacks = null;
82+
const isStrictMode = false;
83+
const concurrentUpdatesByDefaultOverride = false;
84+
const identifierPrefix = 'id';
85+
// TODO: Change error handling to noop. I've added this to more easily develop the reconciler
86+
const onUncaughtError = console.error;
87+
const onCaughtError = console.error;
88+
const onRecoverableError = () => {};
89+
const transitionCallbacks = null;
90+
8091
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
8192
this.container = reconciler.createContainer(
8293
this.rootNode,
83-
// Legacy mode
84-
0,
85-
null,
86-
false,
87-
null,
88-
'id',
89-
() => {},
90-
null,
94+
rootTag,
95+
hydrationCallbacks,
96+
isStrictMode,
97+
concurrentUpdatesByDefaultOverride,
98+
identifierPrefix,
99+
onUncaughtError,
100+
onCaughtError,
101+
onRecoverableError,
102+
transitionCallbacks,
91103
);
92104

93105
// Unmount when process exits

src/reconciler.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import process from 'node:process';
22
import createReconciler from 'react-reconciler';
33
import {
44
DefaultEventPriority,
5-
NoEventPriority
5+
NoEventPriority,
66
} from 'react-reconciler/constants.js';
77
import Yoga, {type Node as YogaNode} from 'yoga-wasm-web/auto';
88
import {
@@ -271,7 +271,8 @@ export default createReconciler<
271271

272272
return {props, style};
273273
},
274-
commitUpdate(node, {props, style}) {
274+
commitUpdate(node, payload, type, oldProps, newProps) {
275+
const {props, style} = newProps;
275276
if (props) {
276277
for (const [key, value] of Object.entries(props)) {
277278
if (key === 'style') {
@@ -304,4 +305,8 @@ export default createReconciler<
304305
removeChildNode(node, removeNode);
305306
cleanupYogaNode(removeNode.yogaNode);
306307
},
308+
maySuspendCommit() {
309+
// TODO: May return false here if we are confident that we don't need to suspend
310+
return true;
311+
},
307312
});

0 commit comments

Comments
 (0)