|
1 | 1 | ---
|
2 | 2 | id: faq-ajax
|
3 |
| -title: AJAX and APIs |
| 3 | +title: AJAX ์ APIs |
4 | 4 | permalink: docs/faq-ajax.html
|
5 | 5 | 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 | +### ์ด๋ป๊ฒ 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 | +๋น์ ์ด ์ ํธํ๋ AJAX ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ React์ ํจ๊ป ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ ๋ช
ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก๋ [Axios](https://github.com/axios/axios), [jQuery AJAX](https://api.jquery.com/jQuery.ajax/), ๊ทธ๋ฆฌ๊ณ ๋ธ๋ผ์ฐ์ ์ ๋ด์ฅ๋ [window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) ๋ฑ์ด ์์ต๋๋ค. |
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 | +### ์ปดํฌ๋ํธ์ ์๋ช
์ฃผ๊ธฐ ์ค ์ด๋์์ 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 | +AJAX ํธ์ถ์ ํตํ ๋ฐ์ดํฐ๋ ์๋ช
์ฃผ๊ธฐ ๋ฉ์๋ ์ค [`componentDidMount`](/docs/react-component.html#mounting) ์์ ์ถ๊ฐ๋์ด์ผ ํฉ๋๋ค. ์ด๋ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์ ์ฌ ๋ `setState`๋ฅผ ํตํ์ฌ ์ปดํฌ๋ํธ๋ฅผ ์
๋ฐ์ดํธํ๊ธฐ ์ํจ์
๋๋ค. |
16 | 16 |
|
17 |
| -### Example: Using AJAX results to set local state {#example-using-ajax-results-to-set-local-state} |
| 17 | +### ์์: ๋ก์ปฌ state๋ฅผ ์ค์ ํ๊ธฐ ์ํด AJAX ๊ฒฐ๊ณผ ์ฌ์ฉํ๊ธฐ {#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 | +์๋ ์ปดํฌ๋ํธ๋ ๋ก์ปฌ ์ปดํฌ๋ํธ์ state๋ฅผ ์ฑ์ฐ๊ธฐ ์ํ์ฌ `componentDidMount` ์์์ ์ด๋ป๊ฒ AJAX ํธ์ถ์ ๋ง๋๋์ง ๋ณด์ฌ ์ค๋๋ค. |
20 | 20 |
|
21 |
| -The example API returns a JSON object like this: |
| 21 | +API ์์๋ ๋ค์๊ณผ ๊ฐ์ JSON ๊ฐ์ฒด๋ฅผ ๋ฐํํฉ๋๋ค. |
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 | + // ์ฃผ์: ์ปดํฌ๋ํธ์ ์ค์ ๋ฒ๊ทธ์์ ๋ฐ์ํ๋ ์์ธ์ฌํญ๋ค์ ๋๊ธฐ์ง ์๋๋ก |
| 54 | + // ์๋ฌ๋ฅผ catch() ๋ธ๋ก(block)์์ ์ฒ๋ฆฌํ๊ธฐ๋ณด๋ค๋ |
| 55 | + // ์ด ๋ถ๋ถ์์ ์ฒ๋ฆฌํ๋ ๊ฒ์ด ์ค์ํฉ๋๋ค. |
56 | 56 | (error) => {
|
57 | 57 | this.setState({
|
58 | 58 | isLoaded: true,
|
|
0 commit comments