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/5/en/part5b.md
+24-25Lines changed: 24 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,7 +121,7 @@ const App = () => {
121
121
}
122
122
```
123
123
124
-
The <i>App</i> components state now contains the boolean <i>loginVisible</i>, which defines if the login form should be shown to the user or not.
124
+
The <i>App</i> component state now contains the boolean <i>loginVisible</i>, which defines if the login form should be shown to the user or not.
125
125
126
126
The value of _loginVisible_ is toggled with two buttons. Both buttons have their event handlers defined directly in the component:
127
127
@@ -284,7 +284,7 @@ React documentation says the [following](https://react.dev/learn/sharing-state-b
284
284
If we think about the state of the forms, so for example the contents of a new note before it has been created, the _App_ component does not need it for anything.
285
285
We could just as well move the state of the forms to the corresponding components.
286
286
287
-
The component for a note changes like so:
287
+
The component for creating a new note changes like so:
288
288
289
289
```js
290
290
import { useState } from'react'
@@ -322,7 +322,7 @@ export default NoteForm
322
322
323
323
**NOTE** At the same time, we changed the behavior of the application so that new notes are important by default, i.e. the field <i>important</i> gets the value <i>true</i>.
324
324
325
-
The <i>newNote</i> state attribute and the event handler responsible for changing it have been moved from the _App_ component to the component responsible for the note form.
325
+
The <i>newNote</i> state variable and the event handler responsible for changing it have been moved from the _App_ component to the component responsible for the note form.
326
326
327
327
There is only one prop left, the _createNote_ function, which the form calls when a new note is created.
328
328
@@ -352,8 +352,7 @@ const App = () => {
352
352
353
353
We could do the same for the log in form, but we'll leave that for an optional exercise.
354
354
355
-
The application code can be found on [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-5),
356
-
branch <i>part5-5</i>.
355
+
The application code can be found on [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-5), branch <i>part5-5</i>.
357
356
358
357
### References to components with ref
359
358
@@ -382,7 +381,7 @@ const App = () => {
382
381
}
383
382
```
384
383
385
-
The [useRef](https://react.dev/reference/react/useRef) hook is used to create a <i>noteFormRef</i> ref, that is assigned to the <i>Togglable</i> component containing the creation note form. The <i>noteFormRef</i> variable acts as a reference to the component. This hook ensures the same reference (ref) that is kept throughout re-renders of the component.
384
+
The [useRef](https://react.dev/reference/react/useRef) hook is used to create a <i>noteFormRef</i> reference, that is assigned to the <i>Togglable</i> component containing the creation note form. The <i>noteFormRef</i> variable acts as a reference to the component. This hook ensures the same reference (ref) that is kept throughout re-renders of the component.
386
385
387
386
We also make the following changes to the <i>Togglable</i> component:
388
387
@@ -492,27 +491,27 @@ The number of moving parts increases. At the same time, the likelihood of ending
492
491
493
492
So we should once more extend our oath:
494
493
495
-
Full stack development is <i>extremely hard</i>, that is why I will use all the possible means to make it easier
494
+
Full stack development is <i>extremely hard</i>, that is why I will use all the possible means to make it easier
496
495
497
496
- I will have my browser developer console open all the time
498
497
- I will use the network tab of the browser dev tools to ensure that frontend and backend are communicating as I expect
499
498
- I will constantly keep an eye on the state of the server to make sure that the data sent there by the frontend is saved there as I expect
500
499
- I will keep an eye on the database: does the backend save data there in the right format
501
500
- I progress with small steps
502
-
- <i>when I suspect that there is a bug in the frontend, I make sure that the backend works for sure</i>
503
-
- <i>when I suspect that there is a bug in the backend, I make sure that the frontend works for sure</i>
501
+
- <i>when I suspect that there is a bug in the frontend, I'll make sure that the backend works as expected</i>
502
+
- <i>when I suspect that there is a bug in the backend, I'll make sure that the frontend works as expected</i>
504
503
- I will write lots of _console.log_ statements to make sure I understand how the code and the tests behave and to help pinpoint problems
505
-
- If my code does not work, I will not write more code. Instead, I start deleting the code until it works or just return to a state when everything was still working
506
-
- If a test does not pass, I make sure that the tested functionality for sure works in the application
507
-
- When I ask for help in the course Discord or Telegram channel or elsewhere I formulate my questions properly, see [here](https://fullstackopen.com/en/part0/general_info#how-to-get-help-in-discord-telegram) how to ask for help
504
+
- If my code does not work, I will not write more code. Instead, I'll start deleting it until it works or will just return to a state where everything was still working
505
+
- If a test does not pass, I'll make sure that the tested functionality works properly in the application
506
+
- When I ask for help in the course Discord or Telegram channel or elsewhere I formulate my questions properly, see [here](/en/part0/general_info#how-to-get-help-in-discord-telegram) how to ask for help
508
507
509
508
</div>
510
509
511
510
<divclass="tasks">
512
511
513
512
### Exercises 5.5.-5.11.
514
513
515
-
#### 5.5 Blog list frontend, step5
514
+
#### 5.5 Blog List Frontend, step 5
516
515
517
516
Change the form for creating blog posts so that it is only displayed when appropriate. Use functionality similar to what was shown [earlier in this part of the course material](/en/part5/props_children_and_proptypes#displaying-the-login-form-only-when-appropriate). If you wish to do so, you can use the <i>Togglable</i> component defined in part 5.
518
517
@@ -524,15 +523,15 @@ It expands when button <i>create new blog</i> is clicked
524
523
525
524

526
525
527
-
The form closes when a new blog is created.
526
+
The form hides again after a new blog is created.
528
527
529
-
#### 5.6 Blog list frontend, step6
528
+
#### 5.6 Blog List Frontend, step 6
530
529
531
530
Separate the form for creating a new blog into its own component (if you have not already done so), and move all the states required for creating a new blog to this component.
532
531
533
532
The component must work like the <i>NoteForm</i> component from the [material](/en/part5/props_children_and_proptypes#state-of-the-forms) of this part.
534
533
535
-
#### 5.7 Blog list frontend, step7
534
+
#### 5.7 Blog List Frontend, step 7
536
535
537
536
Let's add a button to each blog, which controls whether all of the details about the blog are shown or not.
538
537
@@ -568,17 +567,17 @@ const Blog = ({ blog }) => {
568
567
)}
569
568
```
570
569
571
-
**NB:**even though the functionality implemented in this part is almost identical to the functionality provided by the <i>Togglable</i> component, the component can not be used directly to achieve the desired behavior. The easiest solution will be to add a state to the blog post that controls the displayed form of the blog post.
570
+
**NB:**Even though the functionality implemented in this part is almost identical to the functionality provided by the <i>Togglable</i> component, it can't be used directly to achieve the desired behavior. The easiest solution would be to add a state to the blog component that controls if the details are being displayed or not.
572
571
573
-
#### 5.8: Blog list frontend, step8
572
+
#### 5.8: Blog List Frontend, step 8
574
573
575
-
We notice that something is wrong. When a new blog is created in the app, the name of the user that added the blog is not shown in the details of the blog:
574
+
We notice that something is wrong. When a new blog is created in the app, the name of the user that added the blog is not shown in its details:
576
575
577
576

578
577
579
578
When the browser is reloaded, the information of the person is displayed. This is not acceptable, find out where the problem is and make the necessary correction.
580
579
581
-
#### 5.9: Blog list frontend, step9
580
+
#### 5.9: Blog List Frontend, step 9
582
581
583
582
Implement the functionality for the like button. Likes are increased by making an HTTP _PUT_ request to the unique address of the blog post in the backend.
584
583
@@ -615,11 +614,11 @@ The backend has to be updated too to handle the user reference.
615
614
616
615
**One last warning:** if you notice that you are using async/await and the _then_-method in the same code, it is almost certain that you are doing something wrong. Stick to using one or the other, and never use both at the same time "just in case".
617
616
618
-
#### 5.10: Blog list frontend, step10
617
+
#### 5.10: Blog List Frontend, step 10
619
618
620
-
Modify the application to list the blog posts by the number of <i>likes</i>. Sorting the blog posts can be done with the array [sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.
619
+
Modify the application to sort the blog posts by the number of <i>likes</i>. The Sorting can be done with the array [sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.
621
620
622
-
#### 5.11: Blog list frontend, step11
621
+
#### 5.11: Blog List Frontend, step 11
623
622
624
623
Add a new button for deleting blog posts. Also, implement the logic for deleting blog posts in the frontend.
625
624
@@ -768,7 +767,7 @@ module.exports = {
768
767
769
768
NOTE: If you are using Visual Studio Code together with ESLint plugin, you might need to add a workspace setting for it to work. If you are seeing ```Failed to load plugin react: Cannot find module 'eslint-plugin-react'``` additional configuration is needed. Adding the line ```"eslint.workingDirectories": [{ "mode": "auto" }]``` to settings.json in the workspace seems to work. See [here](https://github.com/microsoft/vscode-eslint/issues/880#issuecomment-578052807) for more information.
770
769
771
-
Let's create [.eslintignore](https://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories) file with the following contents to the repository root
770
+
Let's create [.eslintignore](https://eslint.org/docs/latest/use/configure/ignore#the-eslintignore-file) file with the following contents to the repository root
772
771
773
772
```bash
774
773
node_modules
@@ -817,7 +816,7 @@ You can find the code for our current application in its entirety in the <i>part
817
816
818
817
### Exercise 5.12.
819
818
820
-
#### 5.12: Blog list frontend, step12
819
+
#### 5.12: Blog List Frontend, step 12
821
820
822
821
Define PropTypes for one of the components of your application, and add ESlint to the project. Define the configuration according to your liking. Fix all of the linter errors.
Copy file name to clipboardExpand all lines: src/content/5/es/part5a.md
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,8 +86,7 @@ const App = () => {
86
86
exportdefaultApp
87
87
```
88
88
89
-
90
-
El código de aplicación actual se puede encontrar en [GitHub](https://github.com/fullstack-hy2020/part2-notes/tree/part5-1), en la rama <i>part5-1</i>. Si clonas el repositorio, no olvides ejecutar el comando _npm install_ antes de intentar ejecutar el frontend.
89
+
El código de aplicación actual se puede encontrar en [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-1), en la rama <i>part5-1</i>. Si clonas el repositorio, no olvides ejecutar el comando _npm install_ antes de intentar ejecutar el frontend.
91
90
92
91
El frontend no mostrara ninguna nota si no se conecta al backend. Puedes iniciar el backend con el comando _npm run dev_ en su directorio de la Parte 4. Esto ejecutara el backend en el puerto 3001. Mientras esté activo, en una ventana diferente del terminal puedes ejecutar el frontend con _npm start_, y ahora veras las notas que están guardadas en tu base de datos MongoDB de la Parte 4.
93
92
@@ -314,7 +313,7 @@ La solución no es perfecta, pero la dejaremos así por ahora.
314
313
315
314
Nuestro componente principal <i>App</i> es demasiado grande en este momento. Los cambios que hicimos ahora son una clara señal de que los formularios deben ser refactorizados en sus propios componentes. Sin embargo, lo dejaremos para un ejercicio opcional.
316
315
317
-
El código de la aplicación actual se puede encontrar en [GitHub](https://github.com/fullstack-hy2020/part2-notes/tree/part5-2), en la rama <i>part5-2</i>.
316
+
El código de la aplicación actual se puede encontrar en [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-2), en la rama <i>part5-2</i>.
318
317
319
318
### Creando nuevas notas
320
319
@@ -515,7 +514,7 @@ o con el comando que vacía el <i>localstorage</i> por completo:
515
514
window.localStorage.clear()
516
515
```
517
516
518
-
El código de la aplicación actual se puede encontrar en [GitHub](https://github.com/fullstack-hy2020/part2-notes/tree/part5-3), en la rama <i>part5-3</i>.
517
+
El código de la aplicación actual se puede encontrar en [GitHub](https://github.com/fullstack-hy2020/part2-notes-frontend/tree/part5-3), en la rama <i>part5-3</i>.
0 commit comments