Skip to content

Commit

Permalink
Get hello world working
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-sherman committed Apr 11, 2024
1 parent 55965b7 commit 8f006b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
28 changes: 20 additions & 8 deletions src/ink.tsx
Expand Up @@ -77,17 +77,29 @@ export default class Ink {
// so that it's rerendered every time, not just new static parts, like in non-debug mode
this.fullStaticOutput = '';

const rootTag = 1;
const hydrationCallbacks = null;
const isStrictMode = false;
const concurrentUpdatesByDefaultOverride = false;
const identifierPrefix = 'id';
// TODO: Change error handling to noop. I've added this to more easily develop the reconciler
const onUncaughtError = console.error;
const onCaughtError = console.error;
const onRecoverableError = () => {};
const transitionCallbacks = null;

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.container = reconciler.createContainer(
this.rootNode,
// Legacy mode
0,
null,
false,
null,
'id',
() => {},
null,
rootTag,
hydrationCallbacks,
isStrictMode,
concurrentUpdatesByDefaultOverride,
identifierPrefix,
onUncaughtError,
onCaughtError,
onRecoverableError,
transitionCallbacks,
);

// Unmount when process exits
Expand Down
9 changes: 7 additions & 2 deletions src/reconciler.ts
Expand Up @@ -2,7 +2,7 @@ import process from 'node:process';
import createReconciler from 'react-reconciler';
import {
DefaultEventPriority,
NoEventPriority
NoEventPriority,
} from 'react-reconciler/constants.js';
import Yoga, {type Node as YogaNode} from 'yoga-wasm-web/auto';
import {
Expand Down Expand Up @@ -271,7 +271,8 @@ export default createReconciler<

return {props, style};
},
commitUpdate(node, {props, style}) {
commitUpdate(node, payload, type, oldProps, newProps) {
const {props, style} = newProps;
if (props) {
for (const [key, value] of Object.entries(props)) {
if (key === 'style') {
Expand Down Expand Up @@ -304,4 +305,8 @@ export default createReconciler<
removeChildNode(node, removeNode);
cleanupYogaNode(removeNode.yogaNode);
},
maySuspendCommit() {
// TODO: May return false here if we are confident that we don't need to suspend
return true;
},
});

0 comments on commit 8f006b2

Please sign in to comment.