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
Copy file name to clipboardExpand all lines: src/content/2/en/part2c.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,15 +43,15 @@ After installing run the following command to run the json-server. The <i>json-s
43
43
json-server --port 3001--watch db.json
44
44
```
45
45
46
-
However, a global installation is not necessary. From the root directory of your app, we can run the <i>json-server</i> using the command _npx_:
46
+
However, a global installation is not necessary. From the root directory of your app, we can run the <i>json-server</i> using the command _npx_:
47
47
48
48
```js
49
49
npx json-server --port 3001--watch db.json
50
50
```
51
51
52
52
Let's navigate to the address <http://localhost:3001/notes> in the browser. We can see that <i>json-server</i> serves the notes we previously wrote to the file in JSON format:
53
53
54
-

54
+

55
55
56
56
If your browser doesn't have a way to format the display of JSON-data, then install an appropriate plugin, e.g. [JSONVue](https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc) to make your life easier.
57
57
@@ -139,7 +139,7 @@ We could use the previously mentioned promise-based function [fetch](https://dev
139
139
140
140
That being said, we will be using the [axios](https://github.com/axios/axios) library instead for communication between the browser and server. It functions like fetch but is somewhat more pleasant to use. Another good reason to use axios is our getting familiar with adding external libraries, so-called <i>npm packages</i>, to React projects.
141
141
142
-
Nowadays, practically all JavaScript projects are defined using the node package manager, aka [npm](https://docs.npmjs.com/getting-started/what-is-npm). The projects created using Vite also follow the npm format. A clear indicator that a project uses npm is the <i>package.json</i> file located at the root of the project:
142
+
Nowadays, practically all JavaScript projects are defined using the node package manager, aka [npm](https://docs.npmjs.com/about-npm). The projects created using Vite also follow the npm format. A clear indicator that a project uses npm is the <i>package.json</i> file located at the root of the project:
143
143
144
144
```json
145
145
{
@@ -352,10 +352,10 @@ What's not immediately obvious, however, is where the command <em>axios.get</em>
352
352
353
353
### Effect-hooks
354
354
355
-
We have already used [state hooks](https://react.dev/learn/state-a-components-memory) that were introduced along with React version [16.8.0](https://www.npmjs.com/package/react/v/16.8.0), which provide state to React components defined as functions - the so-called <i>functional components</i>. Version 16.8.0 also introduces [effect hooks](https://react.dev/reference/react#effect-hooks) as a new feature. As per the official docs:
355
+
We have already used [state hooks](https://react.dev/learn/state-a-components-memory) that were introduced along with React version [16.8.0](https://www.npmjs.com/package/react/v/16.8.0), which provide state to React components defined as functions - the so-called <i>functional components</i>. Version 16.8.0 also introduces [effect hooks](https://react.dev/reference/react/hooks#effect-hooks) as a new feature. As per the official docs:
356
356
357
-
> <i>The Effect Hook lets you perform side effects on function components.</i>
358
-
> <i>Data fetching, setting up a subscription, and manually changing the DOM in React components are all examples of side effects.</i>
357
+
> <i>Effects let a component connect to and synchronize with external systems.</i>
358
+
> <i>This includes dealing with network, browser DOM, animations, widgets written using a different UI library, and other non-React code.</i>
359
359
360
360
As such, effect hooks are precisely the right tool to use when fetching data from a server.
361
361
@@ -531,7 +531,7 @@ At this point in development, all the parts of the application happen to reside
531
531
532
532
<h3>Exercise 2.11.</h3>
533
533
534
-
<h4>2.11: The Phonebook Step6</h4>
534
+
<h4>2.11: The Phonebook Step 6</h4>
535
535
536
536
We continue with developing the phonebook. Store the initial state of the application in the file <i>db.json</i>, which should be placed in the root of the project.
0 commit comments