« Max reacjsex » : différence entre les versions
Aucun résumé des modifications |
|||
| (8 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
Pour organiser l’arborescence des fichiers JSX et les imports dans une application React, il est important de structurer les fichiers de manière logique et modulaire. Voici une suggestion d’organisation sous forme de tableau, ainsi qu’une indication sur la manière de gérer les imports. | Pour organiser l’arborescence des fichiers JSX et les imports dans une application React, il est important de structurer les fichiers de manière logique et modulaire. Voici une suggestion d’organisation sous forme de tableau, ainsi qu’une indication sur la manière de gérer les imports. | ||
== Exemple == | == '''1.Exemple''' == | ||
<span id="arborescence-des-fichiers-jsx"></span> | <span id="arborescence-des-fichiers-jsx"></span> | ||
=== Arborescence des fichiers JSX === | === Arborescence des fichiers JSX === | ||
| Ligne 90 : | Ligne 90 : | ||
<span id="exemple-de-srccomponentszonetexte.jsx"></span> | <span id="exemple-de-srccomponentszonetexte.jsx"></span> | ||
=== | === <code>/src/components/ZoneTexte.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 100 : | Ligne 100 : | ||
export default ZoneTexte;</syntaxhighlight> | export default ZoneTexte;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentszonenumerique.jsx"></span> | <span id="exemple-de-srccomponentszonenumerique.jsx"></span> | ||
=== | === <code>/src/components/ZoneNumerique.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 110 : | Ligne 110 : | ||
export default ZoneNumerique;</syntaxhighlight> | export default ZoneNumerique;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsbouton.jsx"></span> | <span id="exemple-de-srccomponentsbouton.jsx"></span> | ||
=== | === <code>/src/components/Bouton.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 124 : | Ligne 124 : | ||
export default Bouton;</syntaxhighlight> | export default Bouton;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentscoordxy.jsx"></span> | <span id="exemple-de-srccomponentscoordxy.jsx"></span> | ||
=== | === <code>/src/components/CoordXY.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 140 : | Ligne 140 : | ||
export default CoordXY;</syntaxhighlight> | export default CoordXY;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsgeoloc.jsx"></span> | <span id="exemple-de-srccomponentsgeoloc.jsx"></span> | ||
=== | === <code>/src/components/Geoloc.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React, { useState } from 'react'; | <syntaxhighlight lang="jsx" line copy>import React, { useState } from 'react'; | ||
| Ligne 166 : | Ligne 166 : | ||
export default Geoloc;</syntaxhighlight> | export default Geoloc;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsetage.jsx"></span> | <span id="exemple-de-srccomponentsetage.jsx"></span> | ||
=== | === <code>/src/components/Etage.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 177 : | Ligne 177 : | ||
export default Etage;</syntaxhighlight> | export default Etage;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentscodeacces.jsx"></span> | <span id="exemple-de-srccomponentscodeacces.jsx"></span> | ||
=== | === <code>/src/components/CodeAcces.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 188 : | Ligne 188 : | ||
export default CodeAcces;</syntaxhighlight> | export default CodeAcces;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentscodepos.jsx"></span> | <span id="exemple-de-srccomponentscodepos.jsx"></span> | ||
=== | === <code>/src/components/CodePos.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 199 : | Ligne 199 : | ||
export default CodePos;</syntaxhighlight> | export default CodePos;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsville.jsx"></span> | <span id="exemple-de-srccomponentsville.jsx"></span> | ||
=== | === <code>/src/components/Ville.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 210 : | Ligne 210 : | ||
export default Ville;</syntaxhighlight> | export default Ville;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsadresse.jsx"></span> | <span id="exemple-de-srccomponentsadresse.jsx"></span> | ||
=== | === <code>/src/components/Adresse.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React, { useState } from 'react'; | <syntaxhighlight lang="jsx" line copy>import React, { useState } from 'react'; | ||
| Ligne 247 : | Ligne 247 : | ||
<span id="exemple-de-srccomponentszone.jsx"></span> | <span id="exemple-de-srccomponentszone.jsx"></span> | ||
=== | === <code>/src/components/Zone.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 275 : | Ligne 275 : | ||
export default Zone;</syntaxhighlight> | export default Zone;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsruetourep.jsx"></span> | <span id="exemple-de-srccomponentsruetourep.jsx"></span> | ||
=== | === <code>/src/components/RueToureP.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 286 : | Ligne 286 : | ||
export default RueToureP;</syntaxhighlight> | export default RueToureP;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentstou.jsx"></span> | <span id="exemple-de-srccomponentstou.jsx"></span> | ||
=== | === <code>/src/components/Tou.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 297 : | Ligne 297 : | ||
export default Tou;</syntaxhighlight> | export default Tou;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsrep.jsx"></span> | <span id="exemple-de-srccomponentsrep.jsx"></span> | ||
=== | === <code>/src/components/Rep.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 308 : | Ligne 308 : | ||
export default Rep;</syntaxhighlight> | export default Rep;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsetablissement.jsx"></span> | <span id="exemple-de-srccomponentsetablissement.jsx"></span> | ||
=== | === <code>/src/components/Etablissement.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 319 : | Ligne 319 : | ||
export default Etablissement;</syntaxhighlight> | export default Etablissement;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsformadresse.jsx"></span> | <span id="exemple-de-srccomponentsformadresse.jsx"></span> | ||
=== | === <code>/src/components/FormAdresse.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 334 : | Ligne 334 : | ||
export default FormAdresse;</syntaxhighlight> | export default FormAdresse;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentspage.jsx"></span> | <span id="exemple-de-srccomponentspage.jsx"></span> | ||
=== | === <code>/src/components/Page.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 356 : | Ligne 356 : | ||
export default Page;</syntaxhighlight> | export default Page;</syntaxhighlight> | ||
<span id="exemple-de-srccomponentsapplication.jsx"></span> | <span id="exemple-de-srccomponentsapplication.jsx"></span> | ||
=== | === <code>/src/components/Application.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 371 : | Ligne 371 : | ||
export default Application;</syntaxhighlight> | export default Application;</syntaxhighlight> | ||
<span id="exemple-de-srcapp.jsx"></span> | <span id="exemple-de-srcapp.jsx"></span> | ||
=== | === <code>/src/App.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 386 : | Ligne 386 : | ||
export default App;</syntaxhighlight> | export default App;</syntaxhighlight> | ||
<span id="exemple-de-srcindex.jsx"></span> | <span id="exemple-de-srcindex.jsx"></span> | ||
=== | === <code>/src/index.jsx</code> === | ||
<syntaxhighlight lang="jsx" line copy>import React from 'react'; | <syntaxhighlight lang="jsx" line copy>import React from 'react'; | ||
| Ligne 400 : | Ligne 400 : | ||
Cette structure vous permet de gérer l’état local de chaque composant et de conditionner l’affichage de la ville en fonction de la saisie du code postal. Chaque composant est responsable de sa propre logique et de son rendu, ce qui facilite la maintenance et l’évolution de l’application. | Cette structure vous permet de gérer l’état local de chaque composant et de conditionner l’affichage de la ville en fonction de la saisie du code postal. Chaque composant est responsable de sa propre logique et de son rendu, ce qui facilite la maintenance et l’évolution de l’application. | ||
== | == '''2.Exemple Ville from CodPos''' == | ||
Pour créer un composant <code>Ville</code> qui affiche une liste de villes provenant d’une API fictive et qui se base sur le <code>codePos</code> pour sélectionner la bonne ville, nous allons suivre les étapes suivantes : | Pour créer un composant <code>Ville</code> qui affiche une liste de villes provenant d’une API fictive et qui se base sur le <code>codePos</code> pour sélectionner la bonne ville, nous allons suivre les étapes suivantes : | ||
| Ligne 411 : | Ligne 411 : | ||
<span id="simulation-de-lapi"></span> | <span id="simulation-de-lapi"></span> | ||
=== Simulation de l’API === | === Simulation de l’API === | ||
| Ligne 517 : | Ligne 518 : | ||
[[Category: | == Vidéos == | ||
[https://www.youtube.com/watch?v=1p6TsZW_HDk C'est quoi react (Youtube)] | |||
[[Category:React]] | |||