Skip to content

Commit 1c0c87b

Browse files
adifsgaiddeblasis
andauthored
Translation for the page FAQ APIs and AJAX #79 (#299)
* Translation in a IDEOMATICALY way, for the page FAQ APIs and AJAX #79 * ID delle intestazioni in lingua originale * Traduzione ID in linguar ORIGINALE * Update content/docs/faq-ajax.md Co-authored-by: Alessandro De Blasis <[email protected]> * correzione Co-authored-by: Alessandro De Blasis <[email protected]>
1 parent 7e1b14b commit 1c0c87b

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

content/docs/faq-ajax.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ layout: docs
66
category: FAQ
77
---
88

9-
### How can I make an AJAX call? {#how-can-i-make-an-ajax-call}
9+
### Come posso fare una chiamata AJAX ? {#how-can-i-make-an-ajax-call}
1010

11-
You can use any AJAX library you like with React. Some popular ones are [Axios](https://github.com/axios/axios), [jQuery AJAX](https://api.jquery.com/jQuery.ajax/), and the browser built-in [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
11+
Puoi usare qualsiasi libreria AJAX con React. Le più popolari sono [Axios](https://github.com/axios/axios), [jQuery AJAX](https://api.jquery.com/jQuery.ajax/), e l'API [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) che è integrata nel browser.
1212

13-
### Where in the component lifecycle should I make an AJAX call? {#where-in-the-component-lifecycle-should-i-make-an-ajax-call}
13+
### In quale punto del ciclo di vita del componente devo effettuare una chiamata AJAX? {#where-in-the-component-lifecycle-should-i-make-an-ajax-call}
1414

15-
You should populate data with AJAX calls in the [`componentDidMount`](/docs/react-component.html#mounting) lifecycle method. This is so you can use `setState` to update your component when the data is retrieved.
15+
Dovresti popolare i dati con chiamate AJAX nel metodo [`componentDidMount`](/docs/react-component.html#mounting). In questo modo puoi usare `setState` per aggiornare il tuo componente quando i dati vengono recuperati.
1616

17-
### Example: Using AJAX results to set local state {#example-using-ajax-results-to-set-local-state}
17+
### Esempio: utilizzo dei risultati AJAX per impostare lo stato locale {#example-using-ajax-results-to-set-local-state}
1818

19-
The component below demonstrates how to make an AJAX call in `componentDidMount` to populate local component state.
19+
Il componente seguente mostra come effettuare una chiamata AJAX in `componentDidMount` per popolare lo stato del componente locale.
2020

21-
The example API returns a JSON object like this:
21+
L'API in questione restituisce un oggetto JSON di questo formato:
2222

2323
```
2424
{
@@ -50,9 +50,9 @@ class MyComponent extends React.Component {
5050
items: result.items
5151
});
5252
},
53-
// Note: it's important to handle errors here
54-
// instead of a catch() block so that we don't swallow
55-
// exceptions from actual bugs in components.
53+
// Nota: è importante gestire gli errori qui
54+
// invece di un blocco catch() in modo da non fare passare
55+
// eccezioni da bug reali nei componenti.
5656
(error) => {
5757
this.setState({
5858
isLoaded: true,
@@ -83,17 +83,18 @@ class MyComponent extends React.Component {
8383
}
8484
```
8585

86-
Here is the equivalent with [Hooks](https://reactjs.org/docs/hooks-intro.html):
86+
Ecco l'equivalente con [Hooks](https://reactjs.org/docs/hooks-intro.html):
8787

8888
```js
8989
function MyComponent() {
9090
const [error, setError] = useState(null);
9191
const [isLoaded, setIsLoaded] = useState(false);
9292
const [items, setItems] = useState([]);
9393

94-
// Note: the empty deps array [] means
95-
// this useEffect will run once
96-
// similar to componentDidMount()
94+
95+
// Nota: l'array deps vuoto [] significa
96+
// questo useEffect verrà eseguito una volta
97+
// simile a componentDidMount()
9798
useEffect(() => {
9899
fetch("https://api.example.com/items")
99100
.then(res => res.json())
@@ -102,9 +103,9 @@ function MyComponent() {
102103
setIsLoaded(true);
103104
setItems(result);
104105
},
105-
// Note: it's important to handle errors here
106-
// instead of a catch() block so that we don't swallow
107-
// exceptions from actual bugs in components.
106+
// Nota: è importante gestire gli errori qui
107+
// invece di un blocco catch() in modo da non fare passare
108+
// eccezioni da bug reali nei componenti.
108109
(error) => {
109110
setIsLoaded(true);
110111
setError(error);

0 commit comments

Comments
 (0)