Skip to content

Commit 007d2a3

Browse files
avevladgaearon
authored andcommitted
Translate "AJAX and APIs" into Russian (#30)
* Translate "AJAX and APIs" into Russian * Fix "AJAX and APIs" * Fix "AJAX and APIs"
1 parent 9096b33 commit 007d2a3

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

content/docs/faq-ajax.md

Lines changed: 12 additions & 13 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? {#how-can-i-make-an-ajax-call}
9+
### Как выполнить AJAX-запрос к серверу? {#how-can-i-make-an-ajax-call}
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+
Вы можете использовать встроенный в браузер метод [window.fetch](https://learn.javascript.ru/fetch) или любую AJAX-библиотеку, например [Axios](https://github.com/axios/axios) или [jQuery AJAX](https://api.jquery.com/jQuery.ajax/).
1212

13-
### Where in the component lifecycle should I make an AJAX call? {#where-in-the-component-lifecycle-should-i-make-an-ajax-call}
13+
### Где в жизненном цикле компонента лучше делать запрос? {#where-in-the-component-lifecycle-should-i-make-an-ajax-call}
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 {#example-using-ajax-results-to-set-local-state}
17+
### Пример: Устанавливаем состояние из AJAX-запроса {#example-using-ajax-results-to-set-local-state}
1818

19-
The component below demonstrates how to make an AJAX call in `componentDidMount` to populate local component state.
19+
Компонент ниже показывает, как в `componentDidMount` задать внутреннее состояние из результата AJAX-запроса.
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+
// Примечание: важно обрабатывать ошибки именно здесь, а не в блоке catch(),
54+
// чтобы не перехватывать исключения из ошибок в самих компонентах.
5655
(error) => {
5756
this.setState({
5857
isLoaded: true,
@@ -65,9 +64,9 @@ class MyComponent extends React.Component {
6564
render() {
6665
const { error, isLoaded, items } = this.state;
6766
if (error) {
68-
return <div>Error: {error.message}</div>;
67+
return <div>Ошибка: {error.message}</div>;
6968
} else if (!isLoaded) {
70-
return <div>Loading...</div>;
69+
return <div>Загрузка...</div>;
7170
} else {
7271
return (
7372
<ul>

content/docs/nav.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
- title: FAQ
137137
items:
138138
- id: faq-ajax
139-
title: AJAX and APIs
139+
title: AJAX и обращение к API
140140
- id: faq-build
141141
title: Babel, JSX, and Build Steps
142142
- id: faq-functions

0 commit comments

Comments
 (0)