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
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]>
Copy file name to clipboardExpand all lines: content/docs/faq-ajax.md
+18-17
Original file line number
Diff line number
Diff line change
@@ -6,19 +6,19 @@ layout: docs
6
6
category: FAQ
7
7
---
8
8
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}
10
10
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.
12
12
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}
14
14
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.
16
16
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}
18
18
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.
20
20
21
-
The example API returns a JSON object like this:
21
+
L'API in questione restituisce un oggetto JSON di questo formato:
22
22
23
23
```
24
24
{
@@ -50,9 +50,9 @@ class MyComponent extends React.Component {
50
50
items:result.items
51
51
});
52
52
},
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.
56
56
(error) => {
57
57
this.setState({
58
58
isLoaded:true,
@@ -83,17 +83,18 @@ class MyComponent extends React.Component {
83
83
}
84
84
```
85
85
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):
87
87
88
88
```js
89
89
functionMyComponent() {
90
90
const [error, setError] =useState(null);
91
91
const [isLoaded, setIsLoaded] =useState(false);
92
92
const [items, setItems] =useState([]);
93
93
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()
97
98
useEffect(() => {
98
99
fetch("https://api.example.com/items")
99
100
.then(res=>res.json())
@@ -102,9 +103,9 @@ function MyComponent() {
102
103
setIsLoaded(true);
103
104
setItems(result);
104
105
},
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
0 commit comments