diff --git a/content/docs/faq-ajax.md b/content/docs/faq-ajax.md index 74a9a81e1..caa570d64 100644 --- a/content/docs/faq-ajax.md +++ b/content/docs/faq-ajax.md @@ -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) است. -### 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` کامپوننت را هنگام دریافت داده به‌روزرسانی نمایید. -### 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} -The component below demonstrates how to make an AJAX call in `componentDidMount` to populate local component state. +کامپوننت زیر چگونگی ایجاد یک درخواست AJAX در `componentDidMount` برای پر کردن state محلی کامپوننت را نشان می‌دهد. -The example API returns a JSON object like this: +API استفاده شده در مثال یک شی JSON به شکل زیر برمی‌گرداند: ``` { @@ -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() {