Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| modul:ffit:react:learningunits:lu01:defining-a-component [2024/12/05 06:59] – kdemirci | modul:ffit:react:learningunits:lu01:defining-a-component [2024/12/05 07:08] (aktuell) – kdemirci | ||
|---|---|---|---|
| Zeile 13: | Zeile 13: | ||
| ===== Return markup ===== | ===== Return markup ===== | ||
| - | Every component | + | Each component |
| <code javascript> | <code javascript> | ||
| Zeile 20: | Zeile 20: | ||
| <div> | <div> | ||
| <img src=" | <img src=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | ); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ===== Export the component ===== | ||
| + | |||
| + | Now we have a component. But if we want to use it in other files, we need to export the function. To export a component, you need to add the keywords " | ||
| + | |||
| + | Product.js | ||
| + | <code javascript> | ||
| + | export default function Product() { | ||
| + | return ( | ||
| + | <div> | ||
| + | <img src=" | ||
| + | </ | ||
| + | ); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ProductsList.js | ||
| + | <code javascript> | ||
| + | import Product from ' | ||
| + | |||
| + | export default function ProductsList() { | ||
| + | return ( | ||
| + | <div> | ||
| + | < | ||
| + | <Product /> | ||
| + | <Product /> | ||
| + | <Product /> | ||
| + | <Product /> | ||
| </ | </ | ||
| ); | ); | ||
| } | } | ||
| </ | </ | ||