Skip to content

Commit ae7a928

Browse files
authored
Merge pull request nitin42#6 from ergenekonyigit/master
react and react-reconciler packages upgraded
2 parents 914c3db + 939fd2b commit ae7a928

File tree

7 files changed

+36
-47
lines changed

7 files changed

+36
-47
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## Introduction
1212

13-
This is a small tutorial on how to build your custom React renderer and render the components to the host environment you need. The tutorial is divided into four parts -
13+
This is a small tutorial on how to build your custom React renderer and render the components to the host environment you need. The tutorial is divided into four parts -
1414

1515
* **Part 1** - Creating a React reconciler (using [`react-reconciler`](https://github.com/facebook/react/tree/master/packages/react-reconciler) package).
1616

@@ -28,7 +28,7 @@ In part one, we will create a React reconciler using the [`react-reconciler`](ht
2828

2929
### [Part-II](./part-two.md)
3030

31-
In part two, we will create a public interface to the reconciler i.e a renderer. We will create a custom method for `createElement` and will also architect the component API for our example.
31+
In part two, we will create a public interface to the reconciler i.e a renderer. We will create a custom method for `createElement` and will also architect the component API for our example.
3232

3333
### [Part-III](./part-three.md)
3434

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"dependencies": {
1010
"fbjs": "^0.8.16",
1111
"officegen": "^0.4.5",
12-
"react": "^16.0.0",
13-
"react-reconciler": "^0.2.0"
12+
"react": "^16.2.0",
13+
"react-reconciler": "^0.7.0"
1414
},
1515
"devDependencies": {
1616
"babel-cli": "^6.26.0",
1717
"babel-core": "^6.26.0",
18-
"babel-preset-env": "^1.6.0",
18+
"babel-preset-env": "^1.6.1",
1919
"babel-preset-react": "^6.24.1",
2020
"babel-preset-stage-0": "^6.24.1",
2121
"jest": "^21.2.1"

part-four.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function render(element, filePath) {
2323
WordRenderer.updateContainer(element, node, null);
2424

2525
const output = parse(container).toBuffer();
26-
26+
2727
const stream = fs.createWriteStream(filePath);
2828

2929
await new Promise((resolve, reject) => {
@@ -68,7 +68,7 @@ Finally we parse our input component to render all the children and props and ge
6868

6969
Still having some doubts? Check out the [FAQs](./faq.md).
7070

71-
Congrats! You've have successfully completed the tutorial. Full source code for the tutorial is already available in this repository ([src](./src)). If you want to read the whole source code then follow this order -
71+
Congrats! You've have successfully completed the tutorial. Full source code for the tutorial is already available in this repository ([src](./src)). If you want to read the whole source code then follow this order -
7272

7373
[`reconciler`](./src/reconciler/index.js) => [`components`](./src/components/) => [`createElement`](./src/utils/createElement) => [`parse the input component`](./src/parse/index.js) => [`render method`](./src/render/index.js)
7474

part-one.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Let's get started!
1212
We will first install the dependencies.
1313

1414
```
15-
npm install react-reconciler@0.2.0 fbjs@0.8.16
15+
npm install react-reconciler@0.7.0 fbjs@0.8.16
1616
```
1717

1818
Let's import the `Reconciler` from `react-reconciler` and also the other modules.
@@ -103,27 +103,27 @@ const WordRenderer = Reconciler({
103103
parentInstance.document = child;
104104
}
105105
},
106-
106+
107107
removeChild(parentInstance, child) {
108108
parentInstance.removeChild(child);
109109
},
110110

111111
removeChildFromContainer(parentInstance, child) {
112112
parentInstance.removeChild(child);
113113
},
114-
114+
115115
insertBefore(parentInstance, child, beforeChild) {
116116
// noob
117117
},
118-
118+
119119
commitUpdate(instance, updatePayload, type, oldProps, newProps) {
120120
// noop
121121
},
122-
122+
123123
commitMount(instance, updatePayload, type, oldProps, newProps) {
124124
// noop
125125
},
126-
126+
127127
commitTextUpdate(textInstance, oldText, newText) {
128128
textInstance.children = newText;
129129
},
@@ -141,9 +141,9 @@ Example - Let's say we render,
141141

142142
```js
143143
<Text>Hello World</Text>
144-
```
144+
```
145145

146-
`createInstance` will then return the information about the `type` of an element (' TEXT '), props ( { children: 'Hello World' } ), and the root instance (`WordDocument`).
146+
`createInstance` will then return the information about the `type` of an element (' TEXT '), props ( { children: 'Hello World' } ), and the root instance (`WordDocument`).
147147

148148
**Fiber**
149149

@@ -183,11 +183,11 @@ A fiber is work on a component that needs to be done or was done. Atmost, a comp
183183

184184
**`appendInitialChild`**
185185

186-
It appends the children. If children are wrapped inside a parent component (eg: `Document`), then we will add all the children to it else we
186+
It appends the children. If children are wrapped inside a parent component (eg: `Document`), then we will add all the children to it else we
187187
will create a property called `document` on a parent node and append all the children to it. This will be helpful when we will parse the input component
188188
and make a call to the render method of our component.
189189

190-
Example -
190+
Example -
191191

192192
```js
193193
const data = document.render(); // returns the output
@@ -207,7 +207,7 @@ Renderer mounts the host component but may schedule some work to done after like
207207

208208
**`hostContext`**
209209

210-
Host context is an internal object which our renderer may use based on the current location in the tree. In DOM, this object
210+
Host context is an internal object which our renderer may use based on the current location in the tree. In DOM, this object
211211
is required to make correct calls for example to create an element in html or in MathMl based on current context.
212212

213213
**`getPublicInstance`**
@@ -256,8 +256,6 @@ Creates an instance of a text node.
256256

257257
You can also inject your renderer into react-devtools to debug the host components of your environment. Earlier, it wasn't possible for third party renderers but now using the return value of `reconciler` instance, it is possible to inject the renderer into react-devtools.
258258

259-
> Note - This wasn't supported in `react-reconciler` version 0.2.0. So you'll need to update it to the current beta version 0.3.0-beta.1
260-
261259
**Usage**
262260

263261
Install standalone app for react-devtools

part-three.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ create a function for parsing the input component (input to the `render` method)
1313
const parse = (input) => {
1414
function parseComponent(inputComponent) {
1515
const document = inputComponent.document;
16-
16+
1717
document.render(); // Flush everything
1818

1919
return inputComponent;
@@ -46,13 +46,13 @@ function parseComponent(inputComponent) {
4646
```
4747

4848
In the above function, we create a variable `document` that represents a parentInstance or a component we want to render.
49-
This property is accessible only because of -
49+
This property is accessible only because of -
5050

5151
```js
5252
appendInitialChild(parentInstance, child) {
5353
// if (parentInstance.appendChild) {
5454
// parentInstance.appendChild(child);
55-
// }
55+
// }
5656
else {
5757
parentInstance.document = child; 👈
5858
}

part-two.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ class Document {
4242
constructor(root, props) {
4343
this.root = root;
4444
this.props = props;
45-
45+
4646
// Create a new paragraph
4747
this.adder = this.root.doc.createP();
4848
}
49-
49+
5050
// Add children
5151
appendChild(child) {
5252
this.children.push(child);
5353
}
54-
54+
5555
// Remove children
5656
removeChild(child) {
5757
const index = this.children.indexOf(child);
@@ -83,10 +83,10 @@ Let's see what's going on here!
8383

8484
**`constructor()`**
8585

86-
In our `constructor`, we initialise the `root` instance and `props`. We also create a reference to our `doc` instance which we created earlier in `WordDocument.js`. This reference is then
86+
In our `constructor`, we initialise the `root` instance and `props`. We also create a reference to our `doc` instance which we created earlier in `WordDocument.js`. This reference is then
8787
use to create paragraph by adding text nodes to it.
8888

89-
Example -
89+
Example -
9090

9191
```
9292
this.adder.addText(__someText__)
@@ -136,7 +136,7 @@ class Text {
136136
constructor(root, props) {
137137
this.root = root;
138138
this.props = props;
139-
139+
140140
this.adder = this.root.doc.createP();
141141
}
142142

yarn.lock

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,9 @@ babel-polyfill@^6.26.0:
766766
core-js "^2.5.0"
767767
regenerator-runtime "^0.10.5"
768768

769-
babel-preset-env@^1.6.0:
770-
version "1.6.0"
771-
resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.6.0.tgz#2de1c782a780a0a5d605d199c957596da43c44e4"
769+
babel-preset-env@^1.6.1:
770+
version "1.6.1"
771+
resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.6.1.tgz#a18b564cc9b9afdf4aae57ae3c1b0d99188e6f48"
772772
dependencies:
773773
babel-plugin-check-es2015-constants "^6.22.0"
774774
babel-plugin-syntax-trailing-function-commas "^6.22.0"
@@ -2625,27 +2625,18 @@ rc@^1.1.7:
26252625
minimist "^1.2.0"
26262626
strip-json-comments "~2.0.1"
26272627

2628-
react-dom@^16.0.0:
2629-
version "16.0.0"
2630-
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.0.0.tgz#9cc3079c3dcd70d4c6e01b84aab2a7e34c303f58"
2631-
dependencies:
2632-
fbjs "^0.8.16"
2633-
loose-envify "^1.1.0"
2634-
object-assign "^4.1.1"
2635-
prop-types "^15.6.0"
2636-
2637-
react-reconciler@^0.2.0:
2638-
version "0.2.0"
2639-
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.2.0.tgz#59407c3e868211a7a6218070a55dfbc9c93b2243"
2628+
react-reconciler@^0.7.0:
2629+
version "0.7.0"
2630+
resolved "https://registry.yarnpkg.com/react-reconciler/-/react-reconciler-0.7.0.tgz#9614894103e5f138deeeb5eabaf3ee80eb1d026d"
26402631
dependencies:
26412632
fbjs "^0.8.16"
26422633
loose-envify "^1.1.0"
26432634
object-assign "^4.1.1"
26442635
prop-types "^15.6.0"
26452636

2646-
react@^16.0.0:
2647-
version "16.0.0"
2648-
resolved "https://registry.yarnpkg.com/react/-/react-16.0.0.tgz#ce7df8f1941b036f02b2cca9dbd0cb1f0e855e2d"
2637+
react@^16.2.0:
2638+
version "16.2.0"
2639+
resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba"
26492640
dependencies:
26502641
fbjs "^0.8.16"
26512642
loose-envify "^1.1.0"

0 commit comments

Comments
 (0)