Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
Remove unused code (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamChou19815 authored Apr 26, 2020
1 parent 74996d9 commit 2655b75
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
24 changes: 1 addition & 23 deletions sam-react/src/react-dom.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,12 @@
/** The module bootstraps a react app. */

import { ReactElement, Component, StatefulComponent } from './types';
import { ReactElement, Component } from './types';
import { runEffects } from './renderer-runtime';
import { registerJobRunner, getScheduler } from './react-scheduler';
import { instantiateComponent, mountComponent, updateComponent } from './component-lifecyles';

let rootComponent: Component | null = null;

const patchComponentTreeInplace = (
rootNode: Component,
updatedComponent: StatefulComponent,
oldDOMNode: HTMLElement,
newDOMNode: HTMLElement
): void => {
if (rootNode.type === 'functional') {
if (rootNode.renderedComponent === updatedComponent) {
rootNode.realDOMNode = newDOMNode;
}
patchComponentTreeInplace(rootNode.renderedComponent, updatedComponent, oldDOMNode, newDOMNode);
return;
}
for (let i = 0; i < rootNode.children.length; i += 1) {
const child = rootNode.children[i];
if (child === updatedComponent) {
rootNode.realDOMNode.replaceChild(newDOMNode, oldDOMNode);
break;
}
}
};

registerJobRunner((job) => {
if (rootComponent === null) {
throw new Error();
Expand Down
3 changes: 0 additions & 3 deletions sam-react/src/renderer-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ export const useState = (defaultValue: any): UseStateReturns => {
};

export const useEffect = (effect: () => void): void => {
if (currentComponent === null) {
throw new Error();
}
globalEffectQueue.push(effect);
};

Expand Down

0 comments on commit 2655b75

Please sign in to comment.