Skip to content

Commit 21d6bca

Browse files
authored
Merge pull request #37 from lvillen/review-readmes
Updates README.MD
2 parents 5ec632b + dfc700a commit 21d6bca

7 files changed

Lines changed: 69 additions & 70 deletions

File tree

00-boilerplate/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Starting point for the rest of examples.
66

77
Is just a blank project created using create-react-app.
88

9-
Hop into 01 use state Readme.md and start with the fun :).
9+
Hop into 01-use-state Readme.md and start with the fun :).
1010

1111
# About Basefactor + Lemoncode
1212

01-use-state/Readme.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and can be edited using an **input**.
99

1010
## Steps
1111

12-
- First we copy the previous example, and do a _npm install_
12+
- First we copy the previous example, and do a _npm install_.
1313

1414
```bash
1515
npm install
@@ -36,14 +36,14 @@ export const MyComponent: React.FC = () => {
3636

3737
- Using the reserved word _export_ we can expose this file to other modules.
3838

39-
- It is not strictly necessary to type it with _React.FC_ (Function Component), but It's a good idea, sticking to _Typescript_ will help us to have
39+
- It is not strictly necessary to type it with _React.FC_ (Function Component), but it's a good idea, sticking to _Typescript_ will help us to have
4040
fewer headaches in the future.
4141

4242
- The component is just a function that returns elements from React.
4343
Notice that in this case we have not added _Props_ since it does not consume any.
4444

4545
- Let's go for the interesting part, surely if we use the Java on Angular
46-
mindset, we would ty implementing something like (**IMPORTANT: THIS IS WRONG**).
46+
mindset, we would ty implementing something the following (**IMPORTANT: THIS IS WRONG**).
4747

4848
```diff
4949
export const MyComponent : React.FC = () => {
@@ -64,13 +64,13 @@ export const MyComponent : React.FC = () => {
6464
If you come to a React project and you come across code like this, it's a bad smell, looks like the person that have coded it did not take the time to learn the basics of this library, let's see why:
6565

6666
- When creating a variable, each time the component is repainted, the value
67-
of the variable _myName_ will always be _John Doe_, why? the component
67+
of the variable _myName_ will always be _John Doe_. Why? the component
6868
is just function that is executed over and over on each repaint.
6969

70-
- If we asign a value directly to the _input_ contro, we are skipping to
70+
- If we asign a value directly to the _input_ we are skipping two
7171
main pillars of React: unidirection flow and asynchronous state assignment.
7272

73-
If you want to see it in action (input not working) you just have to add it to the _app.tsx_ file
73+
If you want to see it in action (input not working) you just have to add it to the _app.tsx_ file.
7474

7575
_./src/app.tsx_
7676

@@ -84,7 +84,7 @@ export const App = () => {
8484
};
8585
```
8686

87-
Ok ... How can I handle this? Using React hooks! Let's take a look to _React.useState_, this hook:
87+
Ok... How can I handle this? Using React hooks! Let's take a look to _React.useState_, this hook:
8888

8989
- Is initialized with a default value.
9090

@@ -101,7 +101,7 @@ have a _setName_ or a _setLastname_?
101101

102102
- Let's go and code this component using _Hooks_.
103103

104-
First we make use of the _setState_
104+
First we make use of the _setState_.
105105

106106
_./src/demo.tsx_
107107

@@ -111,7 +111,7 @@ export const MyComponent: React.FC = () => {
111111
+ const [myName, setMyName] = React.useState('John Doe');
112112
```
113113

114-
- As we have named our _getter_ _myName_ it works for us
114+
- As we have named our _getter_ _myName_, it works for us
115115
to both to display the name in the _h4_, as well as in the
116116
_input_
117117

@@ -121,8 +121,8 @@ export const MyComponent: React.FC = () => {
121121

122122
What do we have here?
123123

124-
- \*_e_: argument of the _eventHandler_, gives us information about the event, exposes a series of properties ..
125-
- **e.target**: which DOM element generated the event.
124+
- \*_e_: argument of the _eventHandler_, gives us information about the event, exposes a series of properties.
125+
- **e.target**: which DOM Element generated the event.
126126
- **e.target.value**: what value does this element have (the value property
127127
of the DOM Element that generated the event).
128128

@@ -140,15 +140,15 @@ arguments and pass it to the _myName_ _setState_ function.
140140

141141
How is going to work?
142142

143-
- _setMyName_ request update the state.
143+
- _setMyName_ requests to update the state.
144144
- This will launch a rerender of the component.
145145
- When the component code is executed and reaches the line
146146
code that does the _useState_ instead of return _John Doe_, it will
147147
will supply the name that was stored with _setState_
148148
- When rerendering the component that new value will be shown in the
149149
screen.
150150

151-
You have to change your mindset, ... try to repeat this example
151+
You have to change your mindset, try to repeat this example
152152
without help and understand it well, it is your first big step to understand
153153
how this technology works.
154154

01-use-state/Readme_es.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ un **h4**, y por otro permita editarlo utilizando un **input**.
99

1010
## Paso a Paso
1111

12-
- Primero copiamos el ejemplo anterior, y hacemos un _npm install_
12+
- Primero copiamos el ejemplo anterior y hacemos un _npm install_
1313

1414
```bash
1515
npm install
1616
```
1717

18-
- Vamos a crear un fichero que llamaremos _demo.tsx_, vayamos paso a paso
19-
primero nos importamos **React** ¿Por qué si de primeras no uso nada que
20-
ponga _React._ porque en el momento que empezamos a poner tsx/jsx
21-
(es decir esos _h1_, _input_ o _div_ que después se traducen a
22-
_React.createElement_ es necesario importarlo).
18+
- Vamos a crear un fichero que llamaremos _demo.tsx_. Vayamos paso a paso:
19+
primero nos importamos **React**. ¿Por qué si de primeras no uso nada que
20+
ponga _React_? porque en el momento que empezamos a poner tsx/jsx
21+
(es decir, esos _h1_, _input_ o _div_ que después se traducen a
22+
_React.createElement_) es necesario importarlo.
2323

2424
_demo.tsx_
2525

@@ -41,11 +41,11 @@ export const MyComponent: React.FC = () => {
4141
- No es extrictamente necesario tiparlo con _React.FC_ (Function Component), pero
4242
es buena idea, todo lo que nos atemos a _Typescript_ nos servirá para tener
4343
menos dolores de cabeza en el futuro.
44-
- El componente no es más que una functiona que devuelve elementos de React.
44+
- El componente no es más que una función que devuelve elementos de React.
4545
Fijate que en este caso no hemos puesto _Props_ ya que no consume ninguna
4646
del exterior.
4747

48-
- Vamos a por la parte interesante, seguro que nuestra mente Java on Angular
48+
- Vamos a por la parte interesante, seguro que nuestra mente Java o Angular
4949
nos mueve a implementar lo siguiente (**IMPORTANTE: ESTO ESTA MAL**).
5050

5151
```diff
@@ -66,7 +66,7 @@ export const MyComponent : React.FC = () => {
6666

6767
Si llegáis a un proyecto React y os encontráis código como este, huele a que los
6868
que lo han codificado no se tomaron el tiempo de aprender las bases de esta
69-
librerías, veamos porque:
69+
librerías, veamos por qué:
7070

7171
- Al crear una variable, cada vez que se vuelva a repintar el componente
7272
_myName_ va a valer siempre _John Doe_, esto no deja de ser una función que se
@@ -76,7 +76,7 @@ librerías, veamos porque:
7676
dos de los pilares de React, el flujo unidireccional, y que el seteo del
7777
estado sea asíncrono.
7878

79-
Si queréis verlo en acción sólo tenéis que añadirlo al fichero _app.tsx_
79+
Si queréis verlo en acción sólo tenéis que añadirlo al fichero _app.tsx_.
8080

8181
_./src/app.tsx_
8282

@@ -90,8 +90,8 @@ export const App = () => {
9090
};
9191
```
9292

93-
Vale... ¿Cómo puedo manejar esto? ¡ Con los hooks de React ! Tenemos
94-
_React.useState_
93+
Vale... ¿Cómo puedo manejar esto? ¡Con los hooks de React! Tenemos
94+
_React.useState_.
9595

9696
- Se inicializa con un valor por defecto.
9797

@@ -104,15 +104,15 @@ _React.useState_
104104
nuestro _getter_ y el segundo nuestro \_setter.
105105

106106
¿Por qué narices usa un array? Aquí viene la genialidad, si hubiese devuelto
107-
un objeto, al hacer destructuring del objeto habríamos tenido que cenirños
107+
un objeto, al hacer destructuring del objeto habríamos tenido que ceñirnos
108108
a un nombre concreto de getter y a uno de setter, esto es un rollo porque
109-
en un componente podemos tener multiples state, y además queremos añadirle
110-
sentido a los nombres, ¿Porque tener un _setState_ genérico cuando podemos
109+
en un componente podemos tener múltiples state, y además queremos añadirle
110+
sentido a los nombres, ¿Por qué tener un _setState_ genérico cuando podemos
111111
tener un _setName_ o un _setLastname_?
112112

113-
- Vamos a montar este componente con _Hooks_
113+
- Vamos a montar este componente con _Hooks_.
114114

115-
Primero hacemos uso del _setState_
115+
Primero hacemos uso del _setState_:
116116

117117
_./src/demo.tsx_
118118

@@ -124,20 +124,20 @@ export const MyComponent: React.FC = () => {
124124

125125
- Como hemos nombrado a nuestro _getter_ _myName_ nos vale
126126
tanto para mostrar el nombre en el _h4_, así como en el
127-
_input_
127+
_input_.
128128

129129
- Ahora viene la parte interesante, para poder capturar cuando
130130
el usuario teclea en el input nos suscribimos al evento
131131
_onChange_ (este es un evento estándar de HTML, más info [MDN](https://developer.mozilla.org/es/docs/Web/API/HTMLElement/change_event)).
132132

133-
¿ Qué tenemos aquí?
133+
¿Qué tenemos aquí?
134134

135-
- \*_e_: argumento del _eventHandler_, nos da información del evento, expone una serie de propiedades..
136-
- **e.target**: que DOM elemento genero el evento.
135+
- \*_e_: argumento del _eventHandler_, nos da información del evento, expone una serie de propiedades:
136+
- **e.target**: qué DOM Element generó el evento.
137137
- **e.target.value**: que valor tiene ese elemento (la propiedad valor
138-
del DOM Element que genero el evento).
138+
del DOM Element que generó el evento).
139139

140-
En este event handler aprovecha os para recojer el valor del input y pedir
140+
En este event handler aprovechamos para recoger el valor del input y pedir
141141
setear el estado de _myName_.
142142

143143
```diff
@@ -151,17 +151,17 @@ setear el estado de _myName_.
151151

152152
¿Qué va a provocar esto?
153153

154-
- Que la petición _setMyName_ actualize el estado.
154+
- Que la petición _setMyName_ actualice el estado.
155155
- Esto va a lanzar un repintado del componente.
156156
- Cuando se ejecute el código del componente y llegue a la línea
157-
de código que hace el _useState_ en vez de _John Doe_ se le
157+
de código que hace el _useState_, en vez de _John Doe_ se le
158158
facilitará el nombre que se almaceno con _setState_
159-
- Al repintar el componente se usara ese nuevo valor mostrandolo
159+
- Al repintar el componente se usará ese nuevo valor mostrandolo
160160
por pantalla.
161161

162162
Es un cambio de mentalidad grande,... intenta repetir este ejemplo
163163
sin ayuda y entenderlo bien, es tu primer gran paso para entender
164-
como funciona esta tecnología.
164+
cómo funciona esta tecnología.
165165

166166
# ¿Te apuntas a nuestro máster?
167167

02-use-state-object/Readme.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@
44

55
This example takes the _01-use-state_ as a starting point.
66

7-
In the previous example we stored a string in the state, but
8-
...do we need to use a _useState_ per each basic fild, can we store an object using
9-
useState? Yes you can, but we have to take into consideration that updates on this
7+
In the previous example we stored a string in the state, but... we don't use _useState_ just for basic types. Can we store an object using
8+
_useState_? Yes we can, but we have to take into consideration that updates on this
109
object must be done following the principle of immutability (we never
1110
add an update on a given object, we create a new one).
1211

1312
## Steps
1413

15-
- First we copy the previous example, and execute a _npm install_
14+
- First we copy the previous example, and execute a _npm install_.
1615

1716
```bash
1817
npm install
1918
```
2019

2120
- Let's go store in the state an object that has the name
22-
and last name of a given user, we can write something like:
21+
and last name of a given user. We can write something like:
2322

2423
_./src/demo.tsx_
2524

@@ -32,9 +31,9 @@ export const MyComponent: React.FC = () => {
3231
+ });
3332
```
3433

35-
By doing this we create a state that stores the object, but it would a good idea to
36-
get benefit of using TypeScript and add strong typing, this will help us finding silly bugs
37-
like _Ouch ! I forgot to type the "t" in lastname_.
34+
By doing this we create a state that stores the object, but it would be a good idea to
35+
get benefit of using TypeScript and add strong typing. This will help us finding silly bugs
36+
like _Ouch! I forgot to type the "t" in lastname_.
3837

3938
```diff
4039
+ interface UserInfo {
@@ -50,7 +49,7 @@ export const MyComponent: React.FC = () => {
5049
});
5150
```
5251

53-
- Coold, now that we got our object stored and typed, let's display the user name and lastname.
52+
- Cool, now that we have our object stored and typed, let's display the user's name and lastname.
5453

5554
```diff
5655
return (
@@ -62,9 +61,9 @@ export const MyComponent: React.FC = () => {
6261
);
6362
```
6463

65-
If we start the application we can see how the name and surname are displayed.
64+
If we start the application we can see how the name and lastname are displayed.
6665

67-
- Let's jump on the main thing, updating the name field..., we might be tempted to update userInfo, but this won't
66+
- Let's jump on the main thing, updating the name field... We might be tempted to update userInfo, but this won't
6867
work, anyway let's give a try (**SPOILER ALERT: THIS IS WRONG**):
6968

7069
```diff
@@ -85,8 +84,8 @@ This is not going to work, we are again applying a Java / Angular approach,
8584
we are trying to modify something that is alive only when the function is being
8685
executed, once the component is rerended this value will be lost.
8786

88-
- The way to do this is by creating a new objecto and assigning it using the _setState_
89-
method, in order to do this copy we use the spread operator (by doing this all the fields
87+
- The way to do this is by creating a new object and assigning it using the _setState_
88+
method. In order to do this copy we use the spread operator (by doing this, all the fields
9089
that doesn't change are just passed as they are, they are not recreated).
9190

9291
```diff
@@ -144,7 +143,7 @@ entry for the one that had changes.
144143
```
145144

146145
Now we can test and see that we can update both the name and
147-
surname.
146+
lastname.
148147

149148
# About Basefactor + Lemoncode
150149

02-use-state-object/Readme_es.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
Este ejemplo toma como punto de partida el ejemplo _01-use-state_.
66

7-
En el ejemplo anterior almacenabamos un string en el estado, pero
8-
no todo son tipos básicos, ¿Podemos almacenar un objeto utilizando
9-
useState? Claro que sí, lo único que cuando queremos introducir
7+
En el ejemplo anterior almacenábamos un string en el estado, pero
8+
no todo son tipos básicos. ¿Podemos almacenar un objeto utilizando
9+
_useState_? Claro que sí, lo único que cuando queremos introducir
1010
cambios en el estado tenemos que seguir el principio de inmutabilidad
1111
y no modificar el objeto original.
1212

1313
## Paso a Paso
1414

15-
- Primero copiamos el ejemplo anterior, y hacemos un _npm install_
15+
- Primero copiamos el ejemplo anterior, y hacemos un _npm install_.
1616

1717
```bash
1818
npm install
@@ -33,8 +33,8 @@ export const MyComponent: React.FC = () => {
3333
```
3434

3535
Así creamos un estado al que le almacenamos el objeto, pero nos vendría
36-
bien tener algo de strong typing, que nos ayude a encontrar fallos tontos
37-
del tipo me olvide poner la "t" en lastname.
36+
bien tener algo de strong typing que nos ayude a encontrar fallos tontos
37+
del tipo _me olvide poner la "t" en lastname_.
3838

3939
```diff
4040
+ interface UserInfo {
@@ -63,10 +63,10 @@ export const MyComponent: React.FC = () => {
6363
);
6464
```
6565

66-
- Si arrancamos la aplicación podemos ver como se muestra el nombre y apellido.
66+
- Si arrancamos la aplicación podemos ver cómo se muestra el nombre y apellido.
6767

6868
- Ahora vamos al turrón, podríamos estar tentados de modificar directamente userInfo y
69-
ver que pasa, hacer algo así como (**SPOILER ALERT: ESTO ESTA MAL**):
69+
ver qué pasa, hacer algo así como (**SPOILER ALERT: ESTO ESTA MAL**):
7070

7171
```diff
7272
return (
@@ -110,13 +110,13 @@ que vamos a introducir una modificación.
110110
);
111111
```
112112

113-
Ahora sí que funciona, cuando queremos actualizar _userInfo_ hacemos
113+
Ahora sí que funciona. Cuando queremos actualizar _userInfo_ hacemos
114114
la petición para actualizar el estado y le creamos un objeto nuevo
115-
copiando todas las propiedades del antiguo y como último pasa machacamos
115+
copiando todas las propiedades del antiguo y, como último paso, machacamos
116116
el valor de la propiedad que ha cambiado.
117117

118118
- Vamos a hacer lo mismo para lastname, si quieres dale a la pausa en este
119-
video e intentalo tu por tu cuenta.
119+
video e inténtalo tu por tu cuenta.
120120

121121
```diff
122122
return (

0 commit comments

Comments
 (0)