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: content/docs/faq-ajax.md
+12-12
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,15 @@ layout: docs
6
6
category: FAQ
7
7
---
8
8
9
-
### Come posso fare una chiamata AJAX ? {#come-posso-fare-una-chiamata-ajax}
9
+
### Come posso fare una chiamata AJAX ? {#how-can-i-make-an-ajax-call}
10
10
11
11
Puoi usare qualsiasi libreria AJAX con React. Le piu popolari sono [Axios](https://github.com/axios/axios), [jQuery AJAX](https://api.jquery.com/jQuery.ajax/), e il e il browser integrato [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
12
12
13
-
### In quale punto del ciclo di vita del componente devo effettuare una chiamata AJAX? {#dove-nel-ciclo-di-vita-del-componente-dovrei-fare-una-chiamata-ajax}
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
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
-
### Esempio: utilizzo dei risultati AJAX per impostare lo stato locale {#esempio-usando-ajax-risultati-impostare-lo-stato-locale}
17
+
### Esempio: utilizzo dei risultati AJAX per impostare lo stato locale {#example-using-ajax-results-to-set-local-state}
18
18
19
19
Il componente seguente mostra come effettuare una chiamata AJAX in `componentDidMount` per popolare lo stato del componente locale.
20
20
@@ -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,
@@ -92,9 +92,9 @@ function MyComponent() {
92
92
const [items, setItems] =useState([]);
93
93
94
94
95
-
//Note: the empty deps array [] means
96
-
//this useEffect will run once
97
-
//similar to componentDidMount()
95
+
//Nota: l'array deps vuoto [] significa
96
+
//questo useEffect verrà eseguito una volta
97
+
//simile a componentDidMount()
98
98
useEffect(() => {
99
99
fetch("https://api.example.com/items")
100
100
.then(res=>res.json())
@@ -103,9 +103,9 @@ function MyComponent() {
103
103
setIsLoaded(true);
104
104
setItems(result);
105
105
},
106
-
//Note: it's important to handle errors here
107
-
//instead of a catch() block so that we don't swallow
108
-
//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