Skip to content

Commit ce556dd

Browse files
authored
Merge pull request #10 from ossan-engineer/faq
Translate faq-ajax
2 parents 70c0fb3 + 36ca68d commit ce556dd

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

content/docs/faq-ajax.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
22
id: faq-ajax
3-
title: AJAX and APIs
3+
title: AJAX と API
44
permalink: docs/faq-ajax.html
55
layout: docs
66
category: FAQ
77
---
88

9-
### How can I make an AJAX call?
9+
### AJAX コールをする方法は?
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+
任意の 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) などがあります。
1212

13-
### Where in the component lifecycle should I make an AJAX call?
13+
### コンポーネントのどのライフサイクルで AJAX コールすべきか?
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+
AJAX コールによるデータ取得は[`componentDidMount`](/docs/react-component.html#mounting)のライフサイクルメソッドで行うべきです。データ取得後に `setState` でコンポーネントを更新できるようにするためです。
1616

17-
### Example: Using AJAX results to set local state
17+
### 例:ローカル state に AJAX の通信結果をセットする
1818

19-
The component below demonstrates how to make an AJAX call in `componentDidMount` to populate local component state.
19+
下記のコンポーネントは、 `componentDidMount` で AJAX コールして得られたデータをローカルコンポーネントの state に流し込んでいます。
2020

21-
The example API returns a JSON object like this:
21+
このサンプル API が返す JSON オブジェクトはこのようになります:
2222

2323
```
2424
{
@@ -50,9 +50,8 @@ 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+
// 補足:コンポーネント内のバグによる例外を隠蔽しないためにも
54+
// catch()ブロックの代わりにここでエラーハンドリングすることが重要です
5655
(error) => {
5756
this.setState({
5857
isLoaded: true,

0 commit comments

Comments
 (0)