You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* english improvements for problem 1
* Note about JSX
* The "omitted" sections confused me at first
Omitting them doesn't save a ton of space, and it's not clear that you're not supposed to change them from the previous iteration, so I put them back.
* Better solution to the "omitted" confusion
Now that I've passed this exercise and see that the following exercises use the same pattern, I put things back how they were but added an explanation of how to read the sample
* english improvements for isomorphic problem descr
* improved english problem file for Events exercise
* some improved english explanation in the isomorphic lesson
Copy file name to clipboardExpand all lines: exercises/hello_react/problem.en.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,7 @@ First things first, let's print `Hello World`!
2
2
3
3
First, create the directory where you will write your code. It needs to contain a [package.json](https://docs.npmjs.com/getting-started/using-a-package.json) file
4
4
for npm to know in which folder to install the subsequent packages - `npm init` does this for us.
5
+
5
6
You can change `learnyoureact` to any name you like.
6
7
7
8
`$ mkdir learnyoureact; cd learnyoureact; npm init -y;`
@@ -10,11 +11,9 @@ Start by installing the required modules. Run this command:
Copy file name to clipboardExpand all lines: exercises/isomorphic/problem.en.md
+19-18Lines changed: 19 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,27 @@
1
1
Let's use React on the front-end too!
2
2
3
-
From this exercise on, we'll use React not only on the server side but also on the front-end.
4
-
Let's raise the event on the front-end, and see what will happen.
5
-
In the past exercises, there was some code that raised a front-end event, but it did not work. Where is that?
3
+
From this excercise on, we'll use React not only on the server side but also on the front-end.
4
+
In fact, we'll use the very same view files for rendering both the server-side initial response, and on the front-end for any DOM manipulation necessary. Sharing the code between the front end and the server is a concept known as Isomorphic JavaScript.
6
5
7
-
The code is the check of the `checkbox` event you wrote in `State`.
8
-
At `State`, to tell the truth, you can check the `checkbox` no matter what code you write.
9
-
In this exercise, let's confirm if you can write the right code or not.
10
-
There is a lot of code to change !
11
-
Let's try it!
6
+
In past exercises, there was code that triggered an event in the front-end, but nothing happened. Do you know what it was?
7
+
8
+
It was interactions with the `checkbox` you wrote in the `State` lesson.
9
+
In the `State` lesson, to be honest, checking the `checkbox` doesn't actually update the state.
10
+
11
+
In this excercise, let's make it update `this.state`, which will require running React on the front-end too.
12
+
13
+
There is a lot of code to change!
12
14
13
15
# Question
14
16
---
15
17
16
-
Start by installing the required modules. Run the four commands below.
18
+
Start by installing the required modules. Run the command below:
The above code is to use React at front-end. This code passes `TodoBox` from `index.jsx`, and data from server that are passed in the id of `initial-data` to the element that has the id of`app`.
35
+
The above code is to use React on the front-end. This code assumes that there will be some data attached to a DOM element with the id `initial-data`, and passes it into a `TodoBox` from `index.jsx`, and renders the whole component in the element with id`app`.
34
36
35
-
Next, let's fix `program.js`.
36
-
You can also make a new `program.js` file and write all the code there.
37
+
Next, let's fix `program.js`. You can change your existing one, or make a new `program.js` file and write all the code there.
37
38
38
-
First of all, let's add these `require` statements - like this:
39
+
First of all, let's add some new variables at the top:
39
40
40
41
```
41
42
var React = require('react');
@@ -49,17 +50,17 @@ var browserify = require('browserify');
49
50
var babelify = require("babelify");
50
51
```
51
52
52
-
Next, add a line that reads`index.jsx` under the sentence that `require`s `babel/register`.
53
+
Next, add a line that `require`s`index.jsx` under the line that `require`s `node-jsx`:
53
54
54
55
```
55
56
require('babel/register');
56
57
57
58
var TodoBox = require('./views/index.jsx');
58
59
```
59
60
60
-
Finally, add routes for `/bundle.js` and `/`by copying the code below.
61
-
`/bundle.js`will contain `app.js` and dependencies (view template and react) transformed to ES5 and bundled for the browser.
62
-
Requests to `/`will render the corresponding react view on the server and respond with HTML, including a script tag with `bundle.js` and data from the server for the react view.
61
+
Finally, fix the routes for `/bundle.js` and `/`as shown below.
62
+
When `/bundle.js`is requested, you want to respond with the browserified version of `app.js`, which is transformed to ES5 and will work on the front-end.
63
+
When `/`is requested, you want to respond with a combination of `index.jsx`and the server-side data, and `bundle.js`. This renders the initial state of the application on the server, but allows React to run in the client to continue support state changes.
0 commit comments