You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/reference/react-dom/components/title.md
+27-27Lines changed: 27 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,17 +5,17 @@ canary: true
5
5
6
6
<Canary>
7
7
8
-
React's extensions to `<title>`are currently only available in React's canary and experimental channels. In stable releases of React `<title>`works only as a [built-in browser HTML component](https://react.dev/reference/react-dom/components#all-html-components). Learn more about [React's release channels here](/community/versioning-policy#all-release-channels).
8
+
Les extensions de React à `<title>`ne sont actuellement disponibles que sur les canaux de livraison Canary et Expérimental de React. Dans les versions stables de React,`<title>`fonctionne comme [le composant HTML natif du navigateur](/reference/react-dom/components#all-html-components). Apprenez-en davantage sur [les canaux de livraison React](/community/versioning-policy#all-release-channels).
9
9
10
10
</Canary>
11
11
12
12
13
13
<Intro>
14
14
15
-
The [built-in browser`<title>`component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title)lets you specify the title of the document.
15
+
Le [composant natif`<title>`du navigateur](https://developer.mozilla.org/fr/docs/Web/HTML/Element/title)vous permet de préciser le titre de votre document.
16
16
17
17
```js
18
-
<title>My Blog</title>
18
+
<title>Mon blog</title>
19
19
```
20
20
21
21
</Intro>
@@ -24,45 +24,46 @@ The [built-in browser `<title>` component](https://developer.mozilla.org/en-US/d
24
24
25
25
---
26
26
27
-
## Reference {/*reference*/}
27
+
## Référence {/*reference*/}
28
28
29
29
### `<title>` {/*title*/}
30
30
31
-
To specify the title of the document, render the [built-in browser`<title>`component](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title). You can render`<title>`from any component and React will always place the corresponding DOM element in the document head.
31
+
Pour définir le titre de votre document, utilisez le [composant natif`<title>`du navigateur](https://developer.mozilla.org/fr/docs/Web/HTML/Element/title). Vous pouvez utiliser`<title>`depuis n'importe quel composant et React placera toujours l'élément DOM correspondant dans l'en-tête (`head`) du document.
32
32
33
33
```js
34
-
<title>My Blog</title>
34
+
<title>Mon blog</title>
35
35
```
36
36
37
-
[See more examples below.](#usage)
37
+
[Voir d'autres exemples plus bas](#usage).
38
38
39
39
#### Props {/*props*/}
40
40
41
-
`<title>`supports all [common element props.](/reference/react-dom/components/common#props)
41
+
`<title>`prend en charge toutes les [props communes aux éléments](/reference/react-dom/components/common#props).
42
42
43
-
*`children`: `<title>`accepts only text as a child. This text will become the title of the document. You can also pass your own components as long as they only render text.
43
+
*`children`: `<title>`accepte uniquement du texte comme enfant. Ce texte devient le titre du document. Vous pouvez également passer vos propres composants, du moment que leur rendu aboutit à du texte.
44
44
45
-
#### Special rendering behavior {/*special-rendering-behavior*/}
45
+
#### Comportement spécifique de rendu {/*special-rendering-behavior*/}
46
46
47
-
React will always place the DOM element corresponding to the `<title>`component within the document’s `<head>`, regardless of where in the React tree it is rendered. The`<head>`is the only valid place for `<title>`to exist within the DOM, yet it’s convenient and keeps things composable if a component representing a specific page can render its `<title>`itself.
47
+
React placera toujours l'élément DOM correspondant au composant `<title>`dans le `<head>` du document, peu importe où il figure dans l'arborescence React. Le`<head>`est le seul endroit valide pour un `<title>`dans le DOM, mais il est plus confortable, et préférable en termes de composition, qu'un composant représentant une page donnée puisse produire les composants `<title>`lui-même.
48
48
49
-
There are two exception to this:
50
-
* If `<title>` is within an `<svg>` component, then there is no special behavior, because in this context it doesn’t represent the document’s title but rather is an [accessibility annotation for that SVG graphic](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title).
51
-
* If the `<title>` has an [`itemProp`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemprop) prop, there is no special behavior, because in this case it doesn’t represent the document’s title but rather metadata about a specific part of the page.
49
+
Il y a toutefois deux exceptions :
50
+
51
+
* Si le `<title>` figure au sein d'un composant `<svg>`, aucun comportement spécifique n'est mis en place, parce que dans un tel cas il ne représente pas le titre du document, mais constitue plutôt une [annotation d'accessibilité pour le graphique SVG](https://developer.mozilla.org/fr/docs/Web/SVG/Element/title).
52
+
* Si le `<title>` a une prop [`itemProp`](https://developer.mozilla.org/docs/Web/HTML/Global_attributes/itemprop), aucun comportement spécifique n'est mis en place, parce que dans un tel cas le titre ne s'applique pas au document mais à une partie spécifique de la page.
52
53
53
54
<Pitfall>
54
55
55
-
Only render a single`<title>`at a time. If more than one component renders a `<title>`tag at the same time, React will place all of those titles in the document head. When this happens, the behavior of browsers and search engines is undefined.
56
+
Ne produisez qu'un seul`<title>`à la fois au sein de votre rendu. Si plus d'un composant utilise une balise `<title>`à la fois, React placera l'ensemble de ces titres dans l'en-tête du document. Dans un tel cas, le comportement des navigateurs comme celui des moteurs de recherche n'est pas spécifié.
56
57
57
58
</Pitfall>
58
59
59
60
---
60
61
61
-
## Usage {/*usage*/}
62
+
## Utilisation {/*usage*/}
62
63
63
-
### Set the document title {/*set-the-document-title*/}
64
+
### Définir le titre du document {/*set-the-document-title*/}
64
65
65
-
Render the `<title>`component from any component with text as its children. React will put a `<title>`DOM node in the document `<head>`.
66
+
Utilisez le composant `<title>`dans n'importe quel composant, avec du texte comme enfant. React placera le nœud DOM `<title>`associé dans le `<head>` du document.
66
67
67
68
<SandpackWithHTMLOutput>
68
69
@@ -72,27 +73,26 @@ import ShowRenderedHTML from './ShowRenderedHTML.js';
72
73
exportdefaultfunctionContactUsPage() {
73
74
return (
74
75
<ShowRenderedHTML>
75
-
<title>My Site: Contact Us</title>
76
-
<h1>Contact Us</h1>
77
-
<p>Email us at support@example.com</p>
76
+
<title>Mon site : Contactez-nous</title>
77
+
<h1>Contactez-nous</h1>
78
+
<p>Envoyez-nous un e-mail à support@example.com</p>
78
79
</ShowRenderedHTML>
79
80
);
80
81
}
81
82
```
82
83
83
84
</SandpackWithHTMLOutput>
84
85
85
-
### Use variables in the title {/*use-variables-in-the-title*/}
86
+
### Utiliser des variables dans le titre {/*use-variables-in-the-title*/}
86
87
87
-
The children of the`<title>`component must be a single string of text. (Or a single number or a single object with a `toString` method.) It might not be obvious, but using JSX curly braces like this:
88
+
Les enfants du composant`<title>`doivent être constitués d'une unique chaîne de caractères. (Ou d'un unique nombre, ou d'un unique objet doté d'une méthode `toString`.) Ce qui n'est pas immédiatement évident, c'est qu'en utilisant des expressions JSX comme ci-dessous…
88
89
89
90
```js
90
-
<title>Results page {pageNumber}</title>// 🔴 Problem: This is not a single string
91
+
<title>Page {pageNumber} de résultats</title>// 🔴 Souci : il ne s’agit pas d’un unique texte
91
92
```
92
93
93
-
... actually causes the `<title>`component to get a two-element array as its children (the string `"Results page"` and the value of `pageNumber`). This will cause an error. Instead, use string interpolation to pass `<title>` a single string:
94
+
…le composant `<title>`reçoit en réalité un tableau de trois éléments comme enfants (le texte`"Page "`, la valeur de `pageNumber` et le texte `" de résultats"`). Ça entraînerait une erreur. Utilisez plutôt l'interpolation au sein d'un texte unique passé à `<title>`:
94
95
95
96
```js
96
-
<title>{`Results page ${pageNumber}`}</title>
97
+
<title>{`Page ${pageNumber} de résultats`}</title>
0 commit comments