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

Commit 2655b75

Browse files
authored
Remove unused code (#13)
1 parent 74996d9 commit 2655b75

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

sam-react/src/react-dom.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,12 @@
11
/** The module bootstraps a react app. */
22

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

88
let rootComponent: Component | null = null;
99

10-
const patchComponentTreeInplace = (
11-
rootNode: Component,
12-
updatedComponent: StatefulComponent,
13-
oldDOMNode: HTMLElement,
14-
newDOMNode: HTMLElement
15-
): void => {
16-
if (rootNode.type === 'functional') {
17-
if (rootNode.renderedComponent === updatedComponent) {
18-
rootNode.realDOMNode = newDOMNode;
19-
}
20-
patchComponentTreeInplace(rootNode.renderedComponent, updatedComponent, oldDOMNode, newDOMNode);
21-
return;
22-
}
23-
for (let i = 0; i < rootNode.children.length; i += 1) {
24-
const child = rootNode.children[i];
25-
if (child === updatedComponent) {
26-
rootNode.realDOMNode.replaceChild(newDOMNode, oldDOMNode);
27-
break;
28-
}
29-
}
30-
};
31-
3210
registerJobRunner((job) => {
3311
if (rootComponent === null) {
3412
throw new Error();

sam-react/src/renderer-runtime.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ export const useState = (defaultValue: any): UseStateReturns => {
3939
};
4040

4141
export const useEffect = (effect: () => void): void => {
42-
if (currentComponent === null) {
43-
throw new Error();
44-
}
4542
globalEffectQueue.push(effect);
4643
};
4744

0 commit comments

Comments
 (0)