Last active
September 1, 2023 06:40
-
-
Save anartzdev/4cffdd180a0deb8cd073bf42b4088b4c to your computer and use it in GitHub Desktop.
Props result Qwik
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
import { component$ } from '@builder.io/qwik'; | |
interface TitleProps { | |
greetingText: string; | |
name: string; | |
} | |
export const Title = ({greetingText, name}: TitleProps) => { | |
return <h1>{greetingText} {name}</h1>; | |
}; | |
interface AgeProps { | |
age: number; | |
} | |
export const Age = ({age}: AgeProps) => { | |
return ( | |
<p> | |
{age > 40 | |
? 'Como "tienes más de 40 años", tienes 18 años y más de 22 años de experiencia ;)' | |
: `Eres joven, todavía tienes ${age} años y te faltan ${ | |
40 - age | |
} para volver a cumplir 18 años ;)`} | |
</p> | |
); | |
}; | |
interface HobbiesProps { | |
hobbiesList: string[] | |
} | |
export const Hobbies = ({hobbiesList}: HobbiesProps) => { | |
return ( | |
<ul> | |
{hobbiesList.map((value, index) => ( | |
<li key={index + '_hobby'}> | |
{index + 1} - {value} | |
</li> | |
))} | |
</ul> | |
); | |
}; | |
// Componente principal | |
export default component$(() => { | |
return ( | |
<> | |
<Title greetingText={'Hola'} name={'Anartz'}/> | |
<br /> | |
<Age age={37}/> | |
<Hobbies hobbiesList={['leer', 'deporte', 'videojuegos']}/> | |
<Title greetingText={'Adios'} name={'Qwik'}/> | |
</> | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment