Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FAQ-AJAX and APIs translated #153

Merged
merged 6 commits into from
Jun 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions content/docs/faq-ajax.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
id: faq-ajax
title: AJAX and APIs
title: AJAX و API ها
permalink: docs/faq-ajax.html
layout: docs
category: FAQ
---

### How can I make an AJAX call? {#how-can-i-make-an-ajax-call}
### چگونه یک درخواست 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).
شما می‎توانید از هر کتابخانه 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).
hosseinAMD marked this conversation as resolved.
Show resolved Hide resolved

### Where in the component lifecycle should I make an AJAX call? {#where-in-the-component-lifecycle-should-i-make-an-ajax-call}
### در کدام قسمت چرخه حیات کامپوننت باید درخواست 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 دریافت نمایید. در اینصورت می‎توانید با استفاده از `setState` کامپوننت را هنگام دریافت داده بروزرسانی نمایید.
hosseinAMD marked this conversation as resolved.
Show resolved Hide resolved

### Example: Using AJAX results to set local state {#example-using-ajax-results-to-set-local-state}
### مثال: استفاده از نتایج AJAX برای ست کردن state محلی {#example-using-ajax-results-to-set-local-state}
hosseinAMD marked this conversation as resolved.
Show resolved Hide resolved

The component below demonstrates how to make an AJAX call in `componentDidMount` to populate local component state.
کامپوننت زیر چگونگی ایجاد یک درخواست AJAX در `componentDidMount` برای پر کردن state محلی کامپوننت را نشان می‎دهد.
hosseinAMD marked this conversation as resolved.
Show resolved Hide resolved

The example API returns a JSON object like this:
API استفاده شده در مثال یک شی JSON به شکل زیر برمیگرداند:
hosseinAMD marked this conversation as resolved.
Show resolved Hide resolved

```
{
Expand Down Expand Up @@ -83,7 +83,7 @@ class MyComponent extends React.Component {
}
```

Here is the equivalent with [Hooks](https://reactjs.org/docs/hooks-intro.html):
معادل همین مثال با استفاده از [Hooks](https://reactjs.org/docs/hooks-intro.html):

```js
function MyComponent() {
Expand Down