From e390005735316d23fef08b1310fe35f05533ca2d Mon Sep 17 00:00:00 2001 From: hateonion Date: Mon, 4 Mar 2019 21:44:43 +0800 Subject: [PATCH 01/12] docs(cn): translate docs/faq-ajax.md into Chinese --- content/docs/faq-ajax.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index 102e1c07e7..b46866fab3 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -6,19 +6,19 @@ layout: docs category: FAQ --- -### How can I make an AJAX call? {#how-can-i-make-an-ajax-call} +### 我怎样在React中发起AJAX请求{#how-can-i-make-an-ajax-call} -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). +在React开发中,你能使用任何流行的AJAX库,比如社区比较流行的[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)。 -### Where in the component lifecycle should I make an AJAX call? {#where-in-the-component-lifecycle-should-i-make-an-ajax-call} +### 我应该在React组件的哪个生命周期函数中发起AJAX请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} -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. +我们推荐你在[`componentDidMount`](/docs/react-component.html#mounting)这个生命周期函数中发起AJAX请求。这样做你可以很方便的使用AJAX请求返回回来数据,通过`setState`来更新组件。 -### Example: Using AJAX results to set local state {#example-using-ajax-results-to-set-local-state} +### 用例:使用AJAX请求结果去改变local state{#example-using-ajax-results-to-set-local-state} -The component below demonstrates how to make an AJAX call in `componentDidMount` to populate local component state. +下面这个组件演示了如何在`componentDidMount`中发起AJAX call去更新组件的state。 -The example API returns a JSON object like this: +示例API返回如下的JSON格式。 ``` { @@ -50,9 +50,8 @@ class MyComponent extends React.Component { items: result.items }); }, - // Note: it's important to handle errors here - // instead of a catch() block so that we don't swallow - // exceptions from actual bugs in components. + // 注意:在这里需要通过如下方式来处理错误而不是使用catch()去捕捉错误 + // 因为使用catch去捕捉错误会掩盖掉组件本身可能产生的bug (error) => { this.setState({ isLoaded: true, From 23a684d50f086f8a7fcb541ccee3ed62b25ebf86 Mon Sep 17 00:00:00 2001 From: LeoEatle Date: Tue, 5 Mar 2019 22:31:48 +0800 Subject: [PATCH 02/12] Update content/docs/faq-ajax.md Co-Authored-By: hateonion --- content/docs/faq-ajax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index b46866fab3..3ab7ce75ae 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -8,7 +8,7 @@ category: FAQ ### 我怎样在React中发起AJAX请求{#how-can-i-make-an-ajax-call} -在React开发中,你能使用任何流行的AJAX库,比如社区比较流行的[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)。 +在React开发中,你能使用任何你喜欢的AJAX库,比如社区比较流行的[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)。 ### 我应该在React组件的哪个生命周期函数中发起AJAX请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} From 4bebfd0bc94f03d4e5004fbf00c74d470565507b Mon Sep 17 00:00:00 2001 From: LeoEatle Date: Tue, 5 Mar 2019 22:32:32 +0800 Subject: [PATCH 03/12] Update content/docs/faq-ajax.md Co-Authored-By: hateonion --- content/docs/faq-ajax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index 3ab7ce75ae..b1a56fa53e 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -12,7 +12,7 @@ category: FAQ ### 我应该在React组件的哪个生命周期函数中发起AJAX请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} -我们推荐你在[`componentDidMount`](/docs/react-component.html#mounting)这个生命周期函数中发起AJAX请求。这样做你可以很方便的使用AJAX请求返回回来数据,通过`setState`来更新组件。 +我们推荐你在[`componentDidMount`](/docs/react-component.html#mounting)这个生命周期函数中发起AJAX请求。这样做你可以拿到AJAX请求返回的数据并通过`setState`来更新组件。 ### 用例:使用AJAX请求结果去改变local state{#example-using-ajax-results-to-set-local-state} From 84a71add2a77205bd1d87594a0daaadb337efcd0 Mon Sep 17 00:00:00 2001 From: hateonion Date: Wed, 6 Mar 2019 22:31:45 +0800 Subject: [PATCH 04/12] Update faq-ajax.md --- content/docs/faq-ajax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index b1a56fa53e..9148258928 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -16,7 +16,7 @@ category: FAQ ### 用例:使用AJAX请求结果去改变local state{#example-using-ajax-results-to-set-local-state} -下面这个组件演示了如何在`componentDidMount`中发起AJAX call去更新组件的state。 +下面这个组件演示了如何在`componentDidMount`中发起AJAX请求去更新组件的state。 示例API返回如下的JSON格式。 From 2a5413cabbb056411a79342554b098d6af25523a Mon Sep 17 00:00:00 2001 From: hateonion Date: Mon, 11 Mar 2019 18:06:08 +0800 Subject: [PATCH 05/12] fix space issue --- content/docs/faq-ajax.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index 9148258928..b2ff646c5c 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -6,19 +6,19 @@ layout: docs category: FAQ --- -### 我怎样在React中发起AJAX请求{#how-can-i-make-an-ajax-call} +### 我怎样在 React 中发起 AJAX 请求{#how-can-i-make-an-ajax-call} -在React开发中,你能使用任何你喜欢的AJAX库,比如社区比较流行的[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)。 +在React开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的[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)。 -### 我应该在React组件的哪个生命周期函数中发起AJAX请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} +### 我应该在 React组件 的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} -我们推荐你在[`componentDidMount`](/docs/react-component.html#mounting)这个生命周期函数中发起AJAX请求。这样做你可以拿到AJAX请求返回的数据并通过`setState`来更新组件。 +我们推荐你在[`componentDidMount`](/docs/react-component.html#mounting)这个生命周期函数中发起 AJAX 请求。这样做你可以拿到 AJAX 请求返回的数据并通过 `setState` 来更新组件。 -### 用例:使用AJAX请求结果去改变local state{#example-using-ajax-results-to-set-local-state} +### 用例:使用 AJAX 请求结果去改变 local state {#example-using-ajax-results-to-set-local-state} -下面这个组件演示了如何在`componentDidMount`中发起AJAX请求去更新组件的state。 +下面这个组件演示了如何在 `componentDidMount` 中发起 AJAX 请求去更新组件的 state 。 -示例API返回如下的JSON格式。 +示例 API 返回如下的 JSON 格式。 ``` { @@ -50,8 +50,8 @@ class MyComponent extends React.Component { items: result.items }); }, - // 注意:在这里需要通过如下方式来处理错误而不是使用catch()去捕捉错误 - // 因为使用catch去捕捉错误会掩盖掉组件本身可能产生的bug + // 注意:在这里需要通过如下方式来处理错误而不是使用 catch() 去捕捉错误 + // 因为使用catch去捕捉错误会掩盖掉组件本身可能产生的 bug (error) => { this.setState({ isLoaded: true, From 03f27da74786a3542bdf2850d894683edf14fb79 Mon Sep 17 00:00:00 2001 From: hateonion Date: Mon, 11 Mar 2019 20:12:56 +0800 Subject: [PATCH 06/12] Fix comma and end --- content/docs/faq-ajax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index b2ff646c5c..be89b92ce2 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -8,7 +8,7 @@ category: FAQ ### 我怎样在 React 中发起 AJAX 请求{#how-can-i-make-an-ajax-call} -在React开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的[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)。 +在React开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的[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)。 ### 我应该在 React组件 的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} From 77548564527215323b007216651046a159f700d0 Mon Sep 17 00:00:00 2001 From: hateonion Date: Mon, 11 Mar 2019 22:40:56 +0800 Subject: [PATCH 07/12] add space --- content/docs/faq-ajax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index be89b92ce2..e0cc76125d 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -8,11 +8,11 @@ category: FAQ ### 我怎样在 React 中发起 AJAX 请求{#how-can-i-make-an-ajax-call} -在React开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的[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)。 +在React开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的 [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)。 ### 我应该在 React组件 的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} -我们推荐你在[`componentDidMount`](/docs/react-component.html#mounting)这个生命周期函数中发起 AJAX 请求。这样做你可以拿到 AJAX 请求返回的数据并通过 `setState` 来更新组件。 +我们推荐你在 [`componentDidMount`](/docs/react-component.html#mounting)这个生命周期函数中发起 AJAX 请求。这样做你可以拿到 AJAX 请求返回的数据并通过 `setState` 来更新组件。 ### 用例:使用 AJAX 请求结果去改变 local state {#example-using-ajax-results-to-set-local-state} From afe09f8e4e92b724289a0fced98d61824f9dad21 Mon Sep 17 00:00:00 2001 From: Yuqing Chen Date: Fri, 15 Mar 2019 13:10:26 +0800 Subject: [PATCH 08/12] Update content/docs/faq-ajax.md Co-Authored-By: hateonion --- content/docs/faq-ajax.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index e0cc76125d..8a226e4ec2 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -18,7 +18,7 @@ category: FAQ 下面这个组件演示了如何在 `componentDidMount` 中发起 AJAX 请求去更新组件的 state 。 -示例 API 返回如下的 JSON 格式。 +示例 API 返回如下的 JSON 对象。 ``` { From f5bbb0bfbb89912749233af9e7297589ac2ce5c8 Mon Sep 17 00:00:00 2001 From: Yuqing Chen Date: Fri, 15 Mar 2019 13:11:37 +0800 Subject: [PATCH 09/12] Apply suggestions from code review Co-Authored-By: hateonion --- content/docs/faq-ajax.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index 8a226e4ec2..5114e61817 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -10,11 +10,11 @@ category: FAQ 在React开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的 [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)。 -### 我应该在 React组件 的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} +### 我应该在 React组件的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} -我们推荐你在 [`componentDidMount`](/docs/react-component.html#mounting)这个生命周期函数中发起 AJAX 请求。这样做你可以拿到 AJAX 请求返回的数据并通过 `setState` 来更新组件。 +我们推荐你在 [`componentDidMount`](/docs/react-component.html#mounting) 这个生命周期函数中发起 AJAX 请求。这样做你可以拿到 AJAX 请求返回的数据并通过 `setState` 来更新组件。 -### 用例:使用 AJAX 请求结果去改变 local state {#example-using-ajax-results-to-set-local-state} +### 示例:使用 AJAX 请求结果去改变 local state {#example-using-ajax-results-to-set-local-state} 下面这个组件演示了如何在 `componentDidMount` 中发起 AJAX 请求去更新组件的 state 。 @@ -50,8 +50,8 @@ class MyComponent extends React.Component { items: result.items }); }, - // 注意:在这里需要通过如下方式来处理错误而不是使用 catch() 去捕捉错误 - // 因为使用catch去捕捉错误会掩盖掉组件本身可能产生的 bug + // 注意:在这里需要在此处处理错误而不是使用 catch() 去捕捉错误 + // 因为使用 catch 去捕获异常会掩盖掉组件本身可能产生的 bug (error) => { this.setState({ isLoaded: true, From 4bf7178b93a7a514fa9a928df582148fc21777a3 Mon Sep 17 00:00:00 2001 From: hateonion Date: Sun, 17 Mar 2019 12:52:16 +0800 Subject: [PATCH 10/12] Update faq-ajax.md --- content/docs/faq-ajax.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index 5114e61817..07d50bad7f 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -50,7 +50,8 @@ class MyComponent extends React.Component { items: result.items }); }, - // 注意:在这里需要在此处处理错误而不是使用 catch() 去捕捉错误 + // 注意:在这里需要在此处处理错误 + // 而不是使用 catch() 去捕捉错误 // 因为使用 catch 去捕获异常会掩盖掉组件本身可能产生的 bug (error) => { this.setState({ From 766a0163e959cc11adbe542258e5a80daac7fe84 Mon Sep 17 00:00:00 2001 From: Yuqing Chen Date: Sat, 30 Mar 2019 22:12:44 +0800 Subject: [PATCH 11/12] Apply suggestions from code review Co-Authored-By: hateonion --- content/docs/faq-ajax.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index 07d50bad7f..e48ee771b6 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -8,9 +8,9 @@ category: FAQ ### 我怎样在 React 中发起 AJAX 请求{#how-can-i-make-an-ajax-call} -在React开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的 [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)。 +在 React 开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的 [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)。 -### 我应该在 React组件的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} +### 我应该在 React 组件的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} 我们推荐你在 [`componentDidMount`](/docs/react-component.html#mounting) 这个生命周期函数中发起 AJAX 请求。这样做你可以拿到 AJAX 请求返回的数据并通过 `setState` 来更新组件。 From 196f15c2b74eb69af6b667a49ad239ea14d85948 Mon Sep 17 00:00:00 2001 From: QiChang Li Date: Mon, 1 Apr 2019 12:46:54 +0800 Subject: [PATCH 12/12] Apply suggestions from code review Co-Authored-By: hateonion --- content/docs/faq-ajax.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index e48ee771b6..9372d24585 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -6,19 +6,19 @@ layout: docs category: FAQ --- -### 我怎样在 React 中发起 AJAX 请求{#how-can-i-make-an-ajax-call} +### 如何在 React 中发起 AJAX 请求?{#how-can-i-make-an-ajax-call} 在 React 开发中,你能使用任何你喜欢的 AJAX 库,比如社区比较流行的 [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)。 -### 我应该在 React 组件的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} +### 应该在 React 组件的哪个生命周期函数中发起 AJAX 请求?{#where-in-the-component-lifecycle-should-i-make-an-ajax-call} 我们推荐你在 [`componentDidMount`](/docs/react-component.html#mounting) 这个生命周期函数中发起 AJAX 请求。这样做你可以拿到 AJAX 请求返回的数据并通过 `setState` 来更新组件。 -### 示例:使用 AJAX 请求结果去改变 local state {#example-using-ajax-results-to-set-local-state} +### 示例:使用 AJAX 请求结果去改变组件内部 state {#example-using-ajax-results-to-set-local-state} 下面这个组件演示了如何在 `componentDidMount` 中发起 AJAX 请求去更新组件的 state 。 -示例 API 返回如下的 JSON 对象。 +示例 API 返回如下的 JSON 对象: ``` { @@ -50,8 +50,8 @@ class MyComponent extends React.Component { items: result.items }); }, - // 注意:在这里需要在此处处理错误 - // 而不是使用 catch() 去捕捉错误 + // 注意:需要在此处处理错误 + // 而不是使用 catch() 去捕获错误 // 因为使用 catch 去捕获异常会掩盖掉组件本身可能产生的 bug (error) => { this.setState({