Skip to content

Translation of the page "Lists and Keys" #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 1, 2019
Merged
2 changes: 2 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Glossary of the translations of technical and React-specific terms.
- tag
- lifecycle
- callback
- console
- warning


# Common Translations
Expand Down
252 changes: 126 additions & 126 deletions content/docs/lists-and-keys.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content/docs/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- id: conditional-rendering
title: Conditional Rendering
- id: lists-and-keys
title: Lists and Keys
title: Liste e Chiavi
- id: forms
title: Forms
- id: lifting-state-up
Expand Down
10 changes: 10 additions & 0 deletions examples/lists-and-keys/1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom';

const numeri = [1, 2, 3, 4, 5];
const lista = numeri.map(numero => <li>{numero}</li>);

ReactDOM.render(
<ul>{lista}</ul>,
document.getElementById('root')
);
16 changes: 16 additions & 0 deletions examples/lists-and-keys/2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import ReactDOM from 'react-dom';

function ListaNumeri(props) {
const numeri = props.numeri;
const lista = numeri.map(numero => (
<li key={numero.toString()}>{numero}</li>
));
return <ul>{lista}</ul>;
}

const numeri = [1, 2, 3, 4, 5];
ReactDOM.render(
<ListaNumeri numeri={numeri} />,
document.getElementById('root')
);
22 changes: 22 additions & 0 deletions examples/lists-and-keys/3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import ReactDOM from 'react-dom';

function Numero(props) {
// Corretto! Non è necessario specificare la chiave qui:
return <li>{props.valore}</li>;
}

function ListaNumeri(props) {
const numeri = props.numeri;
const lista = numeri.map(numero => (
// Corretto! La chiave deve essere specificata all'interno dell'array.
<Numero key={numero.toString()} valore={numero} />
));
return <ul>{lista}</ul>;
}

const numeri = [1, 2, 3, 4, 5];
ReactDOM.render(
<ListaNumeri numeri={numeri} />,
document.getElementById('root')
);
42 changes: 42 additions & 0 deletions examples/lists-and-keys/4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import ReactDOM from 'react-dom';

function Blog(props) {
const sidebar = (
<ul>
{props.articoli.map(articolo => (
<li key={articolo.id}>{articolo.titolo}</li>
))}
</ul>
);
const contenuto = props.articoli.map(articolo => (
<div key={articolo.id}>
<h3>{articolo.titolo}</h3>
<p>{articolo.testo}</p>
</div>
));
return (
<div>
{sidebar}
<hr />
{contenuto}
</div>
);
}

const articoli = [
{
id: 1,
titolo: 'Ciao Mondo',
testo: 'Benvenuto in imparando React!',
},
{
id: 2,
titolo: 'Installazione',
testo: 'Puoi installare React usando npm.',
},
];
ReactDOM.render(
<Blog articoli={articoli} />,
document.getElementById('root')
);
23 changes: 23 additions & 0 deletions examples/lists-and-keys/5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import ReactDOM from 'react-dom';

function Numero(props) {
return <li>{props.valore}</li>;
}

function ListaNumeri(props) {
const numeri = props.numeri;
return (
<ul>
{numeri.map(numero => (
<Numero key={numero.toString()} valore={numero} />
))}
</ul>
);
}

const numeri = [1, 2, 3, 4, 5];
ReactDOM.render(
<ListaNumeri numeri={numeri} />,
document.getElementById('root')
);