Skip to content

Commit ac52822

Browse files
authored
Merge pull request #114 from josemoracard/jose3-03-render-with-functions
exercises 03-render-with-functions to 06-listening-to-events
2 parents 461d98f + e6d8ef4 commit ac52822

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+476
-223
lines changed

exercises/03-render-with-functions/README.es.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `03` Render with Functions
1+
# `03` Render with Functions
22

33
JSX permite usar funciones para renderizar HTML, ¡y eso es fantástico!
44

@@ -11,7 +11,7 @@ Por ejemplo:
1111
const PrintHello = () => {
1212
return <h1>Hello World</h1>;
1313
}
14-
//qué //dónde
14+
//qué //dónde
1515
ReactDOM.render(PrintHello(), myDiv);
1616
```
1717

@@ -21,4 +21,4 @@ ReactDOM.render(PrintHello(), myDiv);
2121

2222
## 💡 Pista:
2323

24-
+ La función `PrintHello` comienza con una letra en mayúscula porque la vamos a convertir en un [Componente React](https://reactjs.org/docs/react-component.html) en el próximo ejercicio.
24+
+ La función `PrintHello` comienza con una letra en mayúscula porque la vamos a convertir en un Componente React en el próximo ejercicio.

exercises/03-render-with-functions/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tutorial: "https://www.youtube.com/watch?v=EdpPIo_JNVc"
66

77
JSX allows using functions to render HTML, and that is awesome!
88

9-
It is a strongly recommended practice because, it lets you create templates and re-use your code
9+
It is a strongly recommended practice because it lets you create templates and re-use your code.
1010

1111
For example:
1212

@@ -15,7 +15,7 @@ For example:
1515
const PrintHello = () => {
1616
return <h1>Hello World</h1>;
1717
}
18-
//what //where
18+
//what //where
1919
ReactDOM.render(PrintHello(), myDiv);
2020
```
2121

@@ -25,4 +25,4 @@ ReactDOM.render(PrintHello(), myDiv);
2525

2626
## 💡 Hint:
2727

28-
+ The function `PrintHello` starts with a capital letter because we are going to convert it into a [React Component](https://reactjs.org/docs/react-component.html) in the next exercise.
28+
+ The function `PrintHello` starts with a capital letter because we are going to convert it into a React Component in the next exercise.

exercises/03-render-with-functions/app.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React from "react"; //Main React.js library
1+
import React from "react"; // Main React.js library
22

3-
import ReactDOM from "react-dom"; //we use ReactDOM to render into the DOM
3+
import ReactDOM from "react-dom"; // We use ReactDOM to render into the DOM
44

55
// This function returns a string that will be rendered
66
export const PrintHello = () => {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react"; // Main React.js library
2+
3+
import ReactDOM from "react-dom"; // We use ReactDOM to render into the DOM
4+
5+
// This function returns a string that will be rendered
6+
export const PrintHello = () => {
7+
return <h1>I Love React</h1>;
8+
};
9+
10+
// what where
11+
ReactDOM.render(PrintHello(), document.querySelector("#myDiv"));
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# `03.1` Your first functional component
22

3-
Cuando creas funciones que devuelven HTML, JSX te dejará tratarlos como **Componentes**. Básicamente ellos se convertirán tus propias etiquetas HTML.
3+
Cuando creas funciones que devuelven HTML, JSX te dejará tratarlos como **Componentes**. Básicamente, se convertirán en tus propias etiquetas HTML personalizables.
44

55
> Creando nuestro primer componente funcional
66
77
> Una de las cosas que podemos hacer gracias a JSX es llamar funciones com si fueran etiquetas HTML, por ejemplo:
88
99
```js
10-
// si declaramos una función llamada `MyFunction`
10+
// Si declaramos una función llamada `MyFunction`
1111
const MyFunction = () => {
1212
return <h1>I Love React</h1>;
1313
}
1414

15-
// podemos llamar la función como una etiqueta HTML así
15+
// Podemos llamar la función como una etiqueta HTML así
1616
<MyFunction />
1717

18-
// en vez de hacerlo de la típica forma usando llaves
18+
// En vez de hacerlo de la típica forma usando paréntesis
1919
MyFunction();
2020
```
2121

2222
Cuando llamas a una función así, se convierte en un **Componente de React**, que es una función que genera (devuelve) HTML dinámicamente. Lo que sea que devuelva la función será reemplazado en el mismo lugar que el lugar original del `<MyFunction />`.
2323

2424
## 📝 Instrucciones:
2525

26-
1. En la línea de `app.jsx`, cambia la forma en la que se llama a la función, llama a la función como un **componente React** usando `<` y `>` como una etiqueta HTML (en lugar de paréntesis).
26+
1. En la línea de `app.jsx`, cambia la forma en la que se llama a la función, llama a la función como un **componente React** usando `<` y `>` como una etiqueta HTML (en lugar de paréntesis).

exercises/03.1-your-first-component/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ When you create functions that return HTML, JSX will let you treat them as **Com
1111
> One of the things we can do thanks to JSX is calling functions like they are an HTML tag, for example:
1212
1313
```js
14-
// if we declare a function called MyFunction
14+
// If we declare a function called MyFunction
1515
const MyFunction = () => {
1616
return <h1>I Love React</h1>;
1717
}
1818

19-
// we can call the function as an HTML tag like this:
19+
// We can call the function as an HTML tag like this:
2020
<MyFunction />
2121

22-
// instead of the typical way of using round brackets
22+
// Instead of the typical way of using round brackets
2323
MyFunction();
2424
```
2525

exercises/03.1-your-first-component/app.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export const PrintHello = () => {
55
return <h1>I Love React</h1>;
66
};
77

8-
// change the syntax of the first parameter to make it <PrintHello /> instead of PrintHello()
8+
// Change the syntax of the first parameter to make it <PrintHello /> instead of PrintHello()
99
ReactDOM.render(PrintHello(), document.querySelector("#myDiv"));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
4+
export const PrintHello = () => {
5+
return <h1>I Love React</h1>;
6+
};
7+
8+
// Change the syntax of the first parameter to make it <PrintHello /> instead of PrintHello()
9+
ReactDOM.render(<PrintHello />, document.querySelector("#myDiv"));
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# `03.2` A real component
22

3-
En el ejericio anterior hemos creado nuestro primer componente llamado **PrintHello**, y hemos aprendido que podemos usar el componente como una etiqueta HTML.
3+
En el ejercicio anterior hemos creado nuestro primer componente llamado `PrintHello`, y hemos aprendido que podemos usar el componente como una etiqueta HTML.
44

55
```jsx
66
<PrintHello />
77
```
88

9-
Ahora, vamos a crear un nuevo componente (función) llamado **`<BootstrapCard />`** que generará el siguiente HTML:
9+
Ahora, vamos a crear un nuevo componente (función) llamado `<BootstrapCard />` que generará el siguiente HTML:
1010

1111
```jsx
1212
<div class="card m-5">
@@ -18,12 +18,14 @@ Ahora, vamos a crear un nuevo componente (función) llamado **`<BootstrapCard />
1818
</div>
1919
</div>
2020
```
21-
Nota: Este código HTML está basado en la [Bootstrap Card](https://getbootstrap.com/docs/4.0/components/card/).
21+
> Nota: Este código HTML está basado en la [Bootstrap Card](https://getbootstrap.com/docs/4.0/components/card/).
2222
2323
## 📝 Instrucciones:
2424

2525
1. Por favor, crea una función llamada `BootstrapCard` que devuelva el código de la card y usa la función `ReactDOM.render` para añadir `<BootstrapCard />` dentro del sitio web, dentro de `#myDiv`.
2626

27-
## 💡 Pista:
27+
## 💡 Pistas:
2828

2929
+ Si no sabes o no recuerdas cómo usar `ReactDOM.render`, puedes revisar los ejercicios anteriores.
30+
31+
+ Recuerda usar la sintaxis de React correcta `className` en vez de `class` cuando crees tu tarjeta de bootstrap.

exercises/03.2-a-real-component/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ tutorial: "https://www.youtube.com/watch?v=MGqH3dOhxL4"
44

55
# `03.2` A real component
66

7-
In the past exercise we created our first component called **`PrintHello`**, and we have learned that we can use the component like an HTML tag.
7+
In the past exercise we created our first component called `PrintHello`, and we have learned that we can use the component like an HTML tag.
88

99
```jsx
1010
<PrintHello />
1111
```
1212

13-
Now let's create another component (function) called **`<BootstrapCard />`** that outputs the following HTML:
13+
Now let's create another component (function) called `<BootstrapCard />` that outputs the following HTML:
1414

1515
```jsx
1616
<div class="card m-5">
@@ -23,12 +23,14 @@ Now let's create another component (function) called **`<BootstrapCard />`** tha
2323
</div>
2424
```
2525

26-
Note: This HTML code its based on the [Bootstrap Card](https://getbootstrap.com/docs/4.0/components/card/).
26+
> Note: This HTML code is based on the [Bootstrap Card](https://getbootstrap.com/docs/4.0/components/card/).
2727
2828
## 📝 Instructions:
2929

30-
1. Please create a function called `BootstrapCard` that returns the card code and use the `ReactDOM.render` function `<BootstrapCard />` to add it into the website inside `#myDiv`.
30+
1. Please create a function called `BootstrapCard` that returns the card code and use the `ReactDOM.render` function and `<BootstrapCard />` to add it into the website inside `#myDiv`.
3131

32-
## 💡 Hint:
32+
## 💡 Hints:
3333

3434
+ If you don't know or remember how to use `ReactDOM.render` you can review the past exercises.
35+
36+
+ Remember to use the correct React syntax `className` instead of `class` when creating your bootstrap card.

0 commit comments

Comments
 (0)