Skip to content

Commit 08d1509

Browse files
Translate "Writing markup with jsx" page (#424)
* Traduzione iniziale Writing Markup Tradotto fino a sezione 3 regola camelCase Da revisionare * Translate "Writing Markup with JSX" Tradotto "Writing Markup with JSX" e relativa voce nella sidebar Learn * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> * Update src/content/learn/writing-markup-with-jsx.md Co-authored-by: Mattia Sanfilippo <[email protected]> --------- Co-authored-by: Mattia Sanfilippo <[email protected]>
1 parent b111ec0 commit 08d1509

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

src/content/learn/writing-markup-with-jsx.md

+45-45
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
2-
title: Writing Markup with JSX
2+
title: Scrivere Markup con JSX
33
---
44

55
<Intro>
66

7-
*JSX* is a syntax extension for JavaScript that lets you write HTML-like markup inside a JavaScript file. Although there are other ways to write components, most React developers prefer the conciseness of JSX, and most codebases use it.
7+
*JSX* è un'estensione della sintassi JavaScript che consente di scrivere markup simile all'HTML all'interno di un file JavaScript. Sebbene esistano altri modi per scrivere i componenti, la maggior parte degli sviluppatori React preferisce la concisione di JSX, e la maggior parte dei codebase lo utilizza.
88

99
</Intro>
1010

1111
<YouWillLearn>
1212

13-
* Why React mixes markup with rendering logic
14-
* How JSX is different from HTML
15-
* How to display information with JSX
13+
* Perché React mescola markup e logica di rendering
14+
* Come JSX differisce dall'HTML
15+
* Come visualizzare le informazioni con JSX
1616

1717
</YouWillLearn>
1818

19-
## JSX: Putting markup into JavaScript {/*jsx-putting-markup-into-javascript*/}
19+
## JSX: Inserire il markup in JavaScript {/*jsx-putting-markup-into-javascript*/}
2020

21-
The Web has been built on HTML, CSS, and JavaScript. For many years, web developers kept content in HTML, design in CSS, and logic in JavaScript—often in separate files! Content was marked up inside HTML while the page's logic lived separately in JavaScript:
21+
Il Web è stato costruito su HTML, CSS e JavaScript. Per molti anni, gli sviluppatori Web hanno tenuto il contenuto in HTML, il design in CSS e la logica in JavaScript, spesso in file separati! Il contenuto veniva marcato all'interno dell'HTML mentre la logica della pagina viveva separata in JavaScript:
2222

2323
<DiagramGroup>
2424

@@ -36,37 +36,37 @@ JavaScript
3636

3737
</DiagramGroup>
3838

39-
But as the Web became more interactive, logic increasingly determined content. JavaScript was in charge of the HTML! This is why **in React, rendering logic and markup live together in the same place—components.**
39+
Ma mentre il Web diventava sempre più interattivo, la logica determinava sempre più il contenuto. JavaScript era responsabile dell'HTML! Ecco perché **in React, la logica di rendering e il markup vivono insieme nello stesso posto, ovvero nei componenti.**
4040

4141
<DiagramGroup>
4242

4343
<Diagram name="writing_jsx_sidebar" height={330} width={325} alt="React component with HTML and JavaScript from previous examples mixed. Function name is Sidebar which calls the function isLoggedIn, highlighted in yellow. Nested inside the function highlighted in purple is the p tag from before, and a Form tag referencing the component shown in the next diagram.">
4444

45-
`Sidebar.js` React component
45+
Componente React `Sidebar.js`
4646

4747
</Diagram>
4848

4949
<Diagram name="writing_jsx_form" height={330} width={325} alt="React component with HTML and JavaScript from previous examples mixed. Function name is Form containing two handlers onClick and onSubmit highlighted in yellow. Following the handlers is HTML highlighted in purple. The HTML contains a form element with a nested input element, each with an onClick prop.">
5050

51-
`Form.js` React component
51+
Componente React `Form.js`
5252

5353
</Diagram>
5454

5555
</DiagramGroup>
5656

57-
Keeping a button's rendering logic and markup together ensures that they stay in sync with each other on every edit. Conversely, details that are unrelated, such as the button's markup and a sidebar's markup, are isolated from each other, making it safer to change either of them on their own.
57+
Mantenere la logica di rendering e il markup di un pulsante insieme garantisce che rimangano sincronizzati ogni volta che vengono modificati. Al contrario, i dettagli non correlati, come il markup di un pulsante e il markup di una barra laterale, sono isolati l'uno dall'altro, rendendo più sicuro modificare ognuno di essi da solo.
5858

59-
Each React component is a JavaScript function that may contain some markup that React renders into the browser. React components use a syntax extension called JSX to represent that markup. JSX looks a lot like HTML, but it is a bit stricter and can display dynamic information. The best way to understand this is to convert some HTML markup to JSX markup.
59+
Ogni componente React è una funzione JavaScript che può contenere del markup che React renderizza nel browser. I componenti React utilizzano un'estensione di sintassi chiamata JSX per rappresentare quel markup. JSX assomiglia molto all'HTML, ma è un po' più rigoroso e può visualizzare informazioni dinamiche. La migliore maniera per comprenderlo è quella di convertire un po' di markup HTML in markup JSX.
6060

6161
<Note>
6262

63-
JSX and React are two separate things. They're often used together, but you *can* [use them independently](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#whats-a-jsx-transform) of each other. JSX is a syntax extension, while React is a JavaScript library.
63+
JSX e React sono due cose separate. Sono spesso utilizzati insieme, ma *puoi* [utilizzarli indipendentemente](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#whats-a-jsx-transform) l'uno dall'altro. JSX è un'estensione di sintassi, mentre React è una libreria JavaScript.
6464

6565
</Note>
6666

67-
## Converting HTML to JSX {/*converting-html-to-jsx*/}
67+
## Convertire HTML in JSX {/*converting-html-to-jsx*/}
6868

69-
Suppose that you have some (perfectly valid) HTML:
69+
Supponiamo di avere qualche HTML (perfettamente valido):
7070

7171
```html
7272
<h1>Hedy Lamarr's Todos</h1>
@@ -82,7 +82,7 @@ Suppose that you have some (perfectly valid) HTML:
8282
</ul>
8383
```
8484

85-
And you want to put it into your component:
85+
E di volerlo inserire nel nostro componente:
8686

8787
```js
8888
export default function TodoList() {
@@ -92,7 +92,7 @@ export default function TodoList() {
9292
}
9393
```
9494

95-
If you copy and paste it as is, it will not work:
95+
Se lo copiamo e incolliamo così com'è, non funzionerà:
9696

9797

9898
<Sandpack>
@@ -122,21 +122,21 @@ img { height: 90px }
122122
123123
</Sandpack>
124124
125-
This is because JSX is stricter and has a few more rules than HTML! If you read the error messages above, they'll guide you to fix the markup, or you can follow the guide below.
125+
Ciò è dovuto al fatto che JSX è più rigoroso e ha alcune regole in più rispetto a HTML! Se leggi i messaggi di errore sopra, ti guideranno nella correzione del markup o puoi seguire la guida di seguito.
126126
127127
<Note>
128128
129-
Most of the time, React's on-screen error messages will help you find where the problem is. Give them a read if you get stuck!
129+
La maggior parte delle volte, i messaggi di errore di React ti aiuteranno a trovare il problema. Leggili se ti blocchi!
130130
131131
</Note>
132132
133-
## The Rules of JSX {/*the-rules-of-jsx*/}
133+
## Le Regole di JSX {/*the-rules-of-jsx*/}
134134
135-
### 1. Return a single root element {/*1-return-a-single-root-element*/}
135+
### 1. Restituisci un singolo elemento root {/*1-return-a-single-root-element*/}
136136
137-
To return multiple elements from a component, **wrap them with a single parent tag.**
137+
Per restituire più elementi da un componente, **utilizza un tag padre per wrapparli**
138138
139-
For example, you can use a `<div>`:
139+
Per esempio, puoi usare un `<div>`:
140140
141141
```js {1,11}
142142
<div>
@@ -153,7 +153,7 @@ For example, you can use a `<div>`:
153153
```
154154
155155
156-
If you don't want to add an extra `<div>` to your markup, you can write `<>` and `</>` instead:
156+
Se non vuoi aggiungere un ulteriore `<div>` al tuo markup, puoi scrivere invece `<>` e `</>`:
157157
158158
```js {1,11}
159159
<>
@@ -169,21 +169,21 @@ If you don't want to add an extra `<div>` to your markup, you can write `<>` and
169169
</>
170170
```
171171
172-
This empty tag is called a *[Fragment.](/reference/react/Fragment)* Fragments let you group things without leaving any trace in the browser HTML tree.
172+
Questo tag vuoto è chiamato *[Fragment.](/reference/react/Fragment)* I fragments ti consentono di raggruppare elementi senza lasciare traccia nell'albero HTML del browser.
173173

174174
<DeepDive>
175175

176-
#### Why do multiple JSX tags need to be wrapped? {/*why-do-multiple-jsx-tags-need-to-be-wrapped*/}
176+
#### Perché i tag JSX multipli devono essere wrappati? {/*why-do-multiple-jsx-tags-need-to-be-wrapped*/}
177177

178-
JSX looks like HTML, but under the hood it is transformed into plain JavaScript objects. You can't return two objects from a function without wrapping them into an array. This explains why you also can't return two JSX tags without wrapping them into another tag or a Fragment.
178+
JSX sembra HTML, ma sotto il cofano viene trasformato in semplici oggetti JavaScript. Non è possibile restituire due oggetti da una funzione senza wrapparli in un array. Questo spiega perché non è possibile restituire due tag JSX senza wrapparli in un altro tag o in un Fragment.
179179

180180
</DeepDive>
181181

182-
### 2. Close all the tags {/*2-close-all-the-tags*/}
182+
### 2. Chiudi tutti i tag {/*2-close-all-the-tags*/}
183183

184-
JSX requires tags to be explicitly closed: self-closing tags like `<img>` must become `<img />`, and wrapping tags like `<li>oranges` must be written as `<li>oranges</li>`.
184+
JSX richiede che i tag vengano chiusi esplicitamente: i tag auto-chiusi come `<img>` devono diventare `<img />`, e i tag di wrapping come `<li>oranges` devono essere scritti come `<li>oranges</li>`.
185185

186-
This is how Hedy Lamarr's image and list items look closed:
186+
Ecco come appaiono chiusi l'immagine di Hedy Lamarr e gli elementi della lista:
187187
188188
```js {2-6,8-10}
189189
<>
@@ -200,11 +200,11 @@ This is how Hedy Lamarr's image and list items look closed:
200200
</>
201201
```
202202
203-
### 3. camelCase <s>all</s> most of the things! {/*3-camelcase-salls-most-of-the-things*/}
203+
### 3. Scrivi in camelCase quasi <s>tutte</s> le cose! {/*3-camelcase-salls-most-of-the-things*/}
204204
205-
JSX turns into JavaScript and attributes written in JSX become keys of JavaScript objects. In your own components, you will often want to read those attributes into variables. But JavaScript has limitations on variable names. For example, their names can't contain dashes or be reserved words like `class`.
205+
JSX diventa JavaScript e gli attributi scritti in JSX diventano chiavi degli oggetti JavaScript. Nei propri componenti, spesso si vorrà leggere questi attributi in variabili. Ma JavaScript ha limitazioni sui nomi delle variabili. Ad esempio, i loro nomi non possono contenere trattini o essere parole riservate come `class`.
206206
207-
This is why, in React, many HTML and SVG attributes are written in camelCase. For example, instead of `stroke-width` you use `strokeWidth`. Since `class` is a reserved word, in React you write `className` instead, named after the [corresponding DOM property](https://developer.mozilla.org/en-US/docs/Web/API/Element/className):
207+
Ecco perché in React molti attributi HTML e SVG sono scritti in camelCase. Ad esempio, invece di `stroke-width` si usa `strokeWidth`. Poiché `class` è una parola riservata, in React si scrive `className` invece, nominata in base alla [corrispondente proprietà DOM](https://developer.mozilla.org/en-US/docs/Web/API/Element/className):
208208
209209
```js {4}
210210
<img
@@ -214,19 +214,19 @@ This is why, in React, many HTML and SVG attributes are written in camelCase. Fo
214214
/>
215215
```
216216
217-
You can [find all these attributes in the list of DOM component props.](/reference/react-dom/components/common) If you get one wrong, don't worry—React will print a message with a possible correction to the [browser console.](https://developer.mozilla.org/docs/Tools/Browser_Console)
217+
Puoi [trovare tutti questi attributi nell'elenco delle props del componente DOM.](/reference/react-dom/components/common) Se ne sbagli uno, non preoccuparti: React stamperà un messaggio con una possibile correzione nella [console del browser.](https://developer.mozilla.org/docs/Tools/Browser_Console)
218218

219219
<Pitfall>
220220

221-
For historical reasons, [`aria-*`](https://developer.mozilla.org/docs/Web/Accessibility/ARIA) and [`data-*`](https://developer.mozilla.org/docs/Learn/HTML/Howto/Use_data_attributes) attributes are written as in HTML with dashes.
221+
Per ragioni storiche, gli attributi [`aria-*`](https://developer.mozilla.org/docs/Web/Accessibility/ARIA) e [`data-*`](https://developer.mozilla.org/docs/Learn/HTML/Howto/Use_data_attributes) sono scritti come in HTML con i trattini.
222222

223223
</Pitfall>
224224

225-
### Pro-tip: Use a JSX Converter {/*pro-tip-use-a-jsx-converter*/}
225+
### Pro-tip: Usa un Convertitore JSX {/*pro-tip-use-a-jsx-converter*/}
226226

227-
Converting all these attributes in existing markup can be tedious! We recommend using a [converter](https://transform.tools/html-to-jsx) to translate your existing HTML and SVG to JSX. Converters are very useful in practice, but it's still worth understanding what is going on so that you can comfortably write JSX on your own.
227+
Convertire tutti questi attributi nel markup esistente può essere noioso! Raccomandiamo di utilizzare un [convertitore](https://transform.tools/html-to-jsx) per tradurre il tuo HTML e SVG esistenti in JSX. I convertitori sono molto utili nella pratica, ma è comunque utile capire cosa succede in modo da poter scrivere JSX autonomamente.
228228

229-
Here is your final result:
229+
Ecco il tuo risultato finale:
230230

231231
<Sandpack>
232232

@@ -258,21 +258,21 @@ img { height: 90px }
258258

259259
<Recap>
260260

261-
Now you know why JSX exists and how to use it in components:
261+
Ora sai perché JSX esiste e come usarlo nei componenti:
262262

263-
* React components group rendering logic together with markup because they are related.
264-
* JSX is similar to HTML, with a few differences. You can use a [converter](https://transform.tools/html-to-jsx) if you need to.
265-
* Error messages will often point you in the right direction to fixing your markup.
263+
* I componenti React raggruppano la logica di rendering insieme al markup poiché sono correlati.
264+
* JSX è simile all'HTML, con alcune differenze. Puoi usare un [convertitore](https://transform.tools/html-to-jsx) se ne hai bisogno.
265+
* I messaggi di errore spesso ti indirizzeranno nella giusta direzione per correggere il tuo markup.
266266
267267
</Recap>
268268
269269
270270
271271
<Challenges>
272272
273-
#### Convert some HTML to JSX {/*convert-some-html-to-jsx*/}
273+
#### Converti un po' di HTML in JSX {/*convert-some-html-to-jsx*/}
274274

275-
This HTML was pasted into a component, but it's not valid JSX. Fix it:
275+
Questo HTML è stato copiato in un componente, ma non è un JSX valido. Correggilo:
276276

277277
<Sandpack>
278278

@@ -308,7 +308,7 @@ export default function Bio() {
308308

309309
</Sandpack>
310310

311-
Whether to do it by hand or using the converter is up to you!
311+
Che tu lo faccia a mano o usando il convertitore, dipende da te!
312312

313313
<Solution>
314314

src/sidebarLearn.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"path": "/learn/importing-and-exporting-components"
6161
},
6262
{
63-
"title": "Writing Markup with JSX",
63+
"title": "Scrivere Markup con JSX",
6464
"path": "/learn/writing-markup-with-jsx"
6565
},
6666
{

0 commit comments

Comments
 (0)