-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from josemoracard/jose3-03-render-with-functions
exercises 03-render-with-functions to 06-listening-to-events
- Loading branch information
Showing
54 changed files
with
476 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from "react"; // Main React.js library | ||
|
||
import ReactDOM from "react-dom"; // We use ReactDOM to render into the DOM | ||
|
||
// This function returns a string that will be rendered | ||
export const PrintHello = () => { | ||
return <h1>I Love React</h1>; | ||
}; | ||
|
||
// what where | ||
ReactDOM.render(PrintHello(), document.querySelector("#myDiv")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
# `03.1` Your first functional component | ||
|
||
Cuando creas funciones que devuelven HTML, JSX te dejará tratarlos como **Componentes**. Básicamente ellos se convertirán tus propias etiquetas HTML. | ||
Cuando creas funciones que devuelven HTML, JSX te dejará tratarlos como **Componentes**. Básicamente, se convertirán en tus propias etiquetas HTML personalizables. | ||
|
||
> Creando nuestro primer componente funcional | ||
> Una de las cosas que podemos hacer gracias a JSX es llamar funciones com si fueran etiquetas HTML, por ejemplo: | ||
```js | ||
// si declaramos una función llamada `MyFunction` | ||
// Si declaramos una función llamada `MyFunction` | ||
const MyFunction = () => { | ||
return <h1>I Love React</h1>; | ||
} | ||
|
||
// podemos llamar la función como una etiqueta HTML así | ||
// Podemos llamar la función como una etiqueta HTML así | ||
<MyFunction /> | ||
|
||
// en vez de hacerlo de la típica forma usando llaves | ||
// En vez de hacerlo de la típica forma usando paréntesis | ||
MyFunction(); | ||
``` | ||
|
||
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 />`. | ||
|
||
## 📝 Instrucciones: | ||
|
||
1. En la 9º 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). | ||
1. En la 9ª 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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
|
||
export const PrintHello = () => { | ||
return <h1>I Love React</h1>; | ||
}; | ||
|
||
// Change the syntax of the first parameter to make it <PrintHello /> instead of PrintHello() | ||
ReactDOM.render(<PrintHello />, document.querySelector("#myDiv")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
|
||
//create your function here | ||
// Create your function here | ||
|
||
//remember to use ReactDOM.render to include the component into the website | ||
// Remember to use ReactDOM.render to include the component into the website | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
|
||
// Create your function here | ||
const BootstrapCard = () => { | ||
return ( | ||
<div className="card m-5"> | ||
<img alt="Card image cap" className="card-img-top" src="../../.learn/assets/Dylan.png?raw=true" /> | ||
<div className="card-body"> | ||
<h5 className="card-title">Bob Dylan</h5> | ||
<p className="card-text"> | ||
Bob Dylan (born Robert Allen Zimmerman, May 24, 1941) is an American singer/songwriter, author, and artist who has been an | ||
influential figure in popular music and culture for more than five decades. | ||
</p> | ||
<a className="btn btn-primary" href="https://en.wikipedia.org/wiki/Bob_Dylan"> | ||
Go to wikipedia | ||
</a> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
// Remember to use ReactDOM.render to include the component into the website | ||
ReactDOM.render(<BootstrapCard />, document.getElementById("myDiv")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.