jb-paquet-npm
v1.1.8
Published
https://www.npmjs.com/package/jb-paquet-npm
Downloads
15
Readme
Informations sur le paquet
https://www.npmjs.com/package/jb-paquet-npm
composants
Il existe deux types de composant en React :
Composant fonctionnel : fonction prenant en parametre un objet appele props et retournant du JSX.
Composant a etat : Classe possedant obligatoirement une methode render retournant du JSX, recevant des props et possedant un state representant l etat interne du composant, modifiable en invoquant la fonction setState.
Components ou composant: contient tous les composants generique comme le composant responsable de rendre la vue pour les details d'une page people (PeopleDetail), ou bien celui responsable de l'affichage du contenu riche renseigne dans le CMS (RawHtml).
Composants purs
Un composant pur, pour react, n'est ni plus ni moins qu'une fonction prenant des props (les donnees au format du modele) comme arguments et renvoyant du html (via la syntaxe JSX).
Les composants, par convention, ont un nom ecrit en TitleCase (majuscule sur tous les mots, y compris le premier).
// Ceci est un composant pur renvoyant simplement une div wrappant un titre // dont le texte est donne en props du composant
function MonComposantPur(props) {
return (
<div>
<h1>{props.title}</h1>
</div>
);
}
// Ce composant s'utilise alors de la maniere suivante:
<MonComposantPur title="Super Titre" />
// Cela rendra:
<div>
<h1>Super Titre</h1>
</div>