Skip to content

Commit 158768b

Browse files
committed
Finished k README.md
1 parent f13d18f commit 158768b

File tree

9 files changed

+148
-59
lines changed

9 files changed

+148
-59
lines changed

Diff for: phaseB/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
### Create intrinsic element types
1010

1111
### Create elements
12+
1213
Elements should extend the BaseElement
1314

1415
### Create root element from custom element
16+
1517
The root element should be created from a custom element that logically
1618
sits at the top of the tree
1719

Diff for: phaseD/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ basic concepts remain the same.
1010
### Create node type
1111

1212
### Replace element used for root element
13+
1314
The most critical element to get things working
1415
is the root element, since it is required to
1516
create the root fiber

Diff for: phaseG/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Create intrinsic element types
1010

1111
### Create elements
12+
1213
Remember elements should extend the BaseElement
1314

1415
## Interesting Files

Diff for: phaseH/README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ child
1313

1414
```tsx
1515
<Hello>
16-
<World />
17-
i will trigger a text lifecycle method
16+
<World />i will trigger a text lifecycle method
1817
</Hello>
1918
```
2019

2120
The reconciler text lifecycle methods explicitly specifies the element to use for text
2221

2322
#### createTextInstance
23+
2424
```ts
2525
createTextInstance(
2626
text: string,
@@ -34,6 +34,7 @@ createTextInstance(
3434
```
3535

3636
#### resetTextContent
37+
3738
Because my renderer does not rerender I don't need this.
3839

3940
This probably should be implemented in a sideeffect renderer.
@@ -45,6 +46,7 @@ resetTextContent(_instance: Instance): void {
4546
```
4647

4748
#### commitTextUpdate
49+
4850
Because my renderer does not rerender I don't need this.
4951

5052
This probably should be implemented in a sideeffect renderer.
@@ -60,6 +62,7 @@ commitTextUpdate(
6062
```
6163

6264
#### shouldSetTextContent
65+
6366
This is used to determine if the fiber is a text fiber
6467

6568
```ts
@@ -69,6 +72,10 @@ shouldSetTextContent(_type: Type, props: Props): boolean {
6972
}
7073
```
7174

75+
## Interesting Files
76+
77+
[src/reconciler.ts](src/reconciler.ts)
78+
7279
## Demo
7380

7481
```sh

Diff for: phaseI/README.md

+135-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,141 @@
22

33
> finish reconciler bindings
44
5-
## Usage
5+
## Steps
6+
7+
### Fill out the rest of the reconciler lifecycle methods
8+
9+
#### getPublicInstance
10+
11+
```ts
12+
getPublicInstance(instance: Instance | TextInstance): PublicInstance {
13+
return instance;
14+
}
15+
```
16+
17+
#### prepareForCommit
18+
19+
```ts
20+
prepareForCommit(_containerInfo: Container): void {
21+
// noop
22+
}
23+
```
24+
25+
#### prepareUpdate
26+
27+
```ts
28+
prepareUpdate(
29+
_instance: Instance,
30+
_type: Type,
31+
_oldProps: Props,
32+
_newProps: Props,
33+
_rootContainerInstance: Container,
34+
_hostContext: HostContext
35+
): null | UpdatePayload {
36+
return true;
37+
}
38+
```
39+
40+
#### resetAfterCommit
41+
42+
```ts
43+
resetAfterCommit(_containerInfo: Container): void {
44+
// noop
45+
}
46+
```
47+
48+
#### finalizeInitialChildren
49+
50+
```ts
51+
finalizeInitialChildren(
52+
_parentInstance: Instance,
53+
_type: Type,
54+
_props: Props,
55+
_rootContainerInstance: Container,
56+
_hostContext: HostContext
57+
): boolean {
58+
return true;
59+
}
60+
```
61+
62+
#### commitUpdate
63+
64+
```ts
65+
commitUpdate(
66+
instance: Instance,
67+
_updatePayload: any,
68+
_type: string,
69+
_oldProps: Props,
70+
newProps: Props
71+
): void {
72+
return instance.commitUpdate(newProps);
73+
}
74+
```
75+
76+
#### commitMount
77+
78+
```ts
79+
commitMount(instance: Instance, _type: Type, _newProps: Props): void {
80+
instance.commitMount();
81+
}
82+
```
83+
84+
#### shouldDeprioritizeSubtree
85+
86+
```ts
87+
shouldDeprioritizeSubtree(): boolean {
88+
return true;
89+
}
90+
```
91+
92+
#### scheduleDeferredCallback
93+
94+
```ts
95+
scheduleDeferredCallback(
96+
callback?: () => any,
97+
_options?: { timeout: number }
98+
): any {
99+
if (callback) {
100+
throw new Error(
101+
'Scheduling a callback twice is excessive. Instead, keep track of ' +
102+
'whether the callback has already been scheduled.'
103+
);
104+
}
105+
}
106+
```
107+
108+
#### cancelDeferredCallback
109+
110+
```ts
111+
cancelDeferredCallback(_callbackID: any): void {
112+
// noop
113+
}
114+
```
115+
116+
#### setTimeout
117+
118+
```ts
119+
setTimeout(
120+
handler: (...args: any[]) => void,
121+
timeout: number
122+
): TimeoutHandle | NoTimeout {
123+
return setTimeout(handler, timeout);
124+
}
125+
```
126+
127+
#### clearTimeout
128+
129+
```ts
130+
clearTimeout(handle: TimeoutHandle | NoTimeout): void {
131+
return clearTimeout(handle);
132+
}
133+
```
134+
135+
## Interesting Files
136+
137+
[src/reconciler.ts](src/reconciler.ts)
138+
139+
## Demo
6140

7141
```sh
8142
npm run start

Diff for: phaseI/src/reconciler.ts

-14
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ export default ReactReconciler<
5353
parentInstance.appendChild(child);
5454
},
5555

56-
//
5756
finalizeInitialChildren(
5857
_parentInstance: Instance,
5958
_type: Type,
@@ -76,18 +75,15 @@ export default ReactReconciler<
7675
return label;
7776
},
7877

79-
//
8078
getPublicInstance(instance: Instance | TextInstance): PublicInstance {
8179
log.debug('getPublicInstance');
8280
return instance;
8381
},
8482

85-
//
8683
prepareForCommit(_containerInfo: Container): void {
8784
log.debug('prepareForCommit');
8885
},
8986

90-
//
9187
prepareUpdate(
9288
_instance: Instance,
9389
_type: Type,
@@ -100,7 +96,6 @@ export default ReactReconciler<
10096
return true;
10197
},
10298

103-
//
10499
resetAfterCommit(_containerInfo: Container): void {
105100
log.debug('resetAfterCommit');
106101
},
@@ -160,7 +155,6 @@ export default ReactReconciler<
160155
return false;
161156
},
162157

163-
// @ts-ignore
164158
getRootHostContext(_rootContainerInstance: Container): HostContext {
165159
log.debug('getRootHostContext');
166160
if (dev) log.warn("'getRootHostContext' not supported");
@@ -171,7 +165,6 @@ export default ReactReconciler<
171165
_parentHostContext: HostContext,
172166
_type: Type,
173167
_rootContainerInstance: Container
174-
// @ts-ignore
175168
): HostContext {
176169
log.debug('getChildHostContext');
177170
if (dev) log.warn("'getChildHostContext' not supported");
@@ -180,7 +173,6 @@ export default ReactReconciler<
180173

181174
now: Date.now,
182175

183-
//
184176
commitUpdate(
185177
instance: Instance,
186178
_updatePayload: any,
@@ -192,19 +184,16 @@ export default ReactReconciler<
192184
return instance.commitUpdate(newProps);
193185
},
194186

195-
//
196187
commitMount(instance: Instance, _type: Type, _newProps: Props): void {
197188
log.debug('commitMount');
198189
instance.commitMount();
199190
},
200191

201-
//
202192
shouldDeprioritizeSubtree(): boolean {
203193
log.debug('shouldDeprioritizeSubtree');
204194
return true;
205195
},
206196

207-
//
208197
scheduleDeferredCallback(
209198
callback?: () => any,
210199
_options?: { timeout: number }
@@ -218,13 +207,11 @@ export default ReactReconciler<
218207
}
219208
},
220209

221-
//
222210
cancelDeferredCallback(_callbackID: any): void {
223211
log.debug('cancelDeferredCallback');
224212
// noop
225213
},
226214

227-
//
228215
setTimeout(
229216
handler: (...args: any[]) => void,
230217
timeout: number
@@ -233,7 +220,6 @@ export default ReactReconciler<
233220
return setTimeout(handler, timeout);
234221
},
235222

236-
//
237223
clearTimeout(handle: TimeoutHandle | NoTimeout): void {
238224
log.debug('clearTimeout');
239225
return clearTimeout(handle);

0 commit comments

Comments
 (0)