-
Notifications
You must be signed in to change notification settings - Fork 158
translate updating arrays page to persian #467
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
base: main
Are you sure you want to change the base?
translate updating arrays page to persian #467
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
سلام @KianoshArian عزیز!
از همکاری و وقتی که برای ترجمه مستندات ریاکت فارسی گذاشتی، ممنون هستیم.
در ادامه، تغییرات پیشنهادی رو ارسال میکنم.
همچنین برای اطمینان بیشتر از اینکه همهی اصلاحات کامل انجام شده باشه، میتونید از گزینهی Commit suggestion استفاده کنید.
روش استفاده از این Action رو هم براتون ضمیمه کردم
--- | ||
|
||
<Intro> | ||
|
||
Arrays are mutable in JavaScript, but you should treat them as immutable when you store them in state. Just like with objects, when you want to update an array stored in state, you need to create a new one (or make a copy of an existing one), and then set state to use the new array. | ||
آرایهها در جاوا اسکریپت mutable (قابل تغییر مستقیم) هستند، اما توصیه میشود هنگامی که آنها را در state ذخیره میکنید، با آنها به شکل غیرقابل تغییر برخورد کنید. درست مانند object ها، هنگامی که میخواهید یک آرایه را در state ذخیره کنید، لازم است که یک آرایه جدید ساخته (یا یک آرایه موجود را کپی کنید)، و سپس state را ست کنید تا از آرایه جدید استفاده کنید. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
آرایهها در جاوا اسکریپت mutable (قابل تغییر مستقیم) هستند، اما توصیه میشود هنگامی که آنها را در state ذخیره میکنید، با آنها به شکل غیرقابل تغییر برخورد کنید. درست مانند object ها، هنگامی که میخواهید یک آرایه را در state ذخیره کنید، لازم است که یک آرایه جدید ساخته (یا یک آرایه موجود را کپی کنید)، و سپس state را ست کنید تا از آرایه جدید استفاده کنید. | |
آرایهها در جاوااسکریپت mutable (قابل تغییر مستقیم) هستند، اما توصیه میشود هنگامی که آنها را در state ذخیره میکنید، با آنها به شکل غیرقابل تغییر برخورد کنید. درست مانند objectها، هنگامی که میخواهید یک آرایه را در state ذخیره کنید، لازم است که یک آرایه جدید بسازید (یا یک آرایه موجود را کپی کنید)، و سپس state را به آرایه جدید تنظیم کنید تا از آن استفاده شود. |
|
||
In JavaScript, arrays are just another kind of object. [Like with objects](/learn/updating-objects-in-state), **you should treat arrays in React state as read-only.** This means that you shouldn't reassign items inside an array like `arr[0] = 'bird'`, and you also shouldn't use methods that mutate the array, such as `push()` and `pop()`. | ||
در جاوا اسکریپت، آرایهها تنها یک نوع دیگری از object هستند. [مانند آبجکتها](/learn/updating-objects-in-state)، **شما باید با آرایهها به شکل read-only رفتار کنید.** این یعنی شما نباید آیتمهای آرایه را به شکل `arr[0] = 'bird'` مقدار دهی مجدد کنید، و همچنین نباید از متدهایی که آرایه را mutate میکنند، همچون `push()` و `pop()` استفاده کنید. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
در جاوا اسکریپت، آرایهها تنها یک نوع دیگری از object هستند. [مانند آبجکتها](/learn/updating-objects-in-state)، **شما باید با آرایهها به شکل read-only رفتار کنید.** این یعنی شما نباید آیتمهای آرایه را به شکل `arr[0] = 'bird'` مقدار دهی مجدد کنید، و همچنین نباید از متدهایی که آرایه را mutate میکنند، همچون `push()` و `pop()` استفاده کنید. | |
در جاوااسکریپت، آرایهها نوعی object هستند. [مانند objectها](/learn/updating-objects-in-state)، **باید با آرایهها در state بهصورت فقطخواندنی رفتار کنید.** این یعنی نباید آیتمهای یک آرایه را با `arr[0] = 'bird'` دوباره مقداردهی کنید، و همچنین نباید از متدهایی که آرایه را تغییر میدهند، مانند `push()` و `pop()`، استفاده کنید. |
|
||
Instead, every time you want to update an array, you'll want to pass a *new* array to your state setting function. To do that, you can create a new array from the original array in your state by calling its non-mutating methods like `filter()` and `map()`. Then you can set your state to the resulting new array. | ||
در عوض، هر بار که میخواهید یک آرایه را به روز رسانی کنید، باید یک آرایه *جدید* را به تابع ست state خود بدهید. برای انجام این عمل، شما میتوانید با فراخوانی متدهای non-mutating همچون `filter()` و `map()` یک آرایه جدید از آرایه اصلی بسازید. سپس، میتوانید state را با آرایه حاصل جدید ست کنید. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
در عوض، هر بار که میخواهید یک آرایه را به روز رسانی کنید، باید یک آرایه *جدید* را به تابع ست state خود بدهید. برای انجام این عمل، شما میتوانید با فراخوانی متدهای non-mutating همچون `filter()` و `map()` یک آرایه جدید از آرایه اصلی بسازید. سپس، میتوانید state را با آرایه حاصل جدید ست کنید. | |
در عوض، هر بار که میخواهید یک آرایه را بهروزرسانی کنید، باید یک آرایه *جدید* را به تابع تنظیم state خود بدهید. برای این کار میتوانید با فراخوانی متدهای بدون تغییر (non-mutating) مانند `filter()` و `map()` یک آرایه جدید از آرایه اصلی بسازید. سپس میتوانید state را به آرایه جدید تنظیم کنید. |
|
||
Here is a reference table of common array operations. When dealing with arrays inside React state, you will need to avoid the methods in the left column, and instead prefer the methods in the right column: | ||
در اینجا یک جدول مرجع از عملیاتهای رایج بر روی آرایهها را مشاهده میکنید. در هنگام کار کردن با آرایهها در state ریاکت، باید از استفاده از متدهای ستون سمت راست خودداری کرده، و در عوض از متدهای ستون سمت چپ استفاده کنید: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
در اینجا یک جدول مرجع از عملیاتهای رایج بر روی آرایهها را مشاهده میکنید. در هنگام کار کردن با آرایهها در state ریاکت، باید از استفاده از متدهای ستون سمت راست خودداری کرده، و در عوض از متدهای ستون سمت چپ استفاده کنید: | |
در اینجا یک جدول مرجع از عملیات رایج روی آرایهها آورده شده است. هنگام کار با آرایهها در state ریاکت، باید از متدهای ستون سمت چپ پرهیز کنید و در عوض متدهای ستون سمت راست را ترجیح دهید. |
|
||
| | avoid (mutates the array) | prefer (returns a new array) | | ||
| | خودداری شود (آرایه را mutate میکند) | ترجیح داده شود (آرایه جدید ایجاد میکند) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| | خودداری شود (آرایه را mutate میکند) | ترجیح داده شود (آرایه جدید ایجاد میکند) | | |
| | خودداری شود (آرایه را تغییر میدهد) | ترجیح داده شود (آرایه جدید ایجاد میکند) | |
@@ -1410,9 +1410,9 @@ ul, li { margin: 0; padding: 0; } | |||
</Solution> | |||
|
|||
|
|||
#### Fix the mutations using Immer {/*fix-the-mutations-using-immer*/} | |||
#### اصلاح mutation ها با استفاده از Immer {/*fix-the-mutations-using-immer*/} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#### اصلاح mutation ها با استفاده از Immer {/*fix-the-mutations-using-immer*/} | |
#### اصلاح تغییرها با استفاده از Immer {/*fix-the-mutations-using-immer*/} |
|
||
This is the same example as in the previous challenge. This time, fix the mutations by using Immer. For your convenience, `useImmer` is already imported, so you need to change the `todos` state variable to use it. | ||
این مثال مشابه چالش قبلی است. این بار، mutation ها را با استفاده از Immer اصلاح کنید. برای راحتی شما، `useImmer` از قبل import شده است، پس باید متغیر state `todos` را تغییر دهید تا از آن استفاده کنید. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
این مثال مشابه چالش قبلی است. این بار، mutation ها را با استفاده از Immer اصلاح کنید. برای راحتی شما، `useImmer` از قبل import شده است، پس باید متغیر state `todos` را تغییر دهید تا از آن استفاده کنید. | |
این مثال مشابه چالش قبلی است. این بار، تغییرها را با استفاده از Immer اصلاح کنید. برای راحتی شما، `useImmer` از قبل import شده است، پس باید متغیر state `todos` را تغییر دهید تا از آن استفاده کنید. |
@@ -1594,7 +1594,7 @@ ul, li { margin: 0; padding: 0; } | |||
|
|||
<Solution> | |||
|
|||
With Immer, you can write code in the mutative fashion, as long as you're only mutating parts of the `draft` that Immer gives you. Here, all mutations are performed on the `draft` so the code works: | |||
با استفاده از Immer، میتوانید کد را به شکل mutative بنویسید، به شرطی که تنها قسمتهایی از `draft` که Immer در اختیارتان میگذارد را mutate کنید. در اینجا، تمامی mutation ها بر روی `draft` اعمال شده اند، بنابراین کد به درستی کار میکند: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
با استفاده از Immer، میتوانید کد را به شکل mutative بنویسید، به شرطی که تنها قسمتهایی از `draft` که Immer در اختیارتان میگذارد را mutate کنید. در اینجا، تمامی mutation ها بر روی `draft` اعمال شده اند، بنابراین کد به درستی کار میکند: | |
با استفاده از Immer، میتوانید کد را بهصورت تغییرپذیر بنویسید، به شرط آنکه تنها بخشهایی از `draft` را تغییر دهید که Immer در اختیارتان میگذارد. در اینجا تمام تغییرها روی `draft` انجام شدهاند؛ بنابراین کد بهدرستی کار میکند: |
@@ -1780,9 +1780,9 @@ ul, li { margin: 0; padding: 0; } | |||
|
|||
</Sandpack> | |||
|
|||
You can also mix and match the mutative and non-mutative approaches with Immer. | |||
شما همچنین میتوانید روشهای mutative و non-mutative را با Immer ترکیب کنید. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
شما همچنین میتوانید روشهای mutative و non-mutative را با Immer ترکیب کنید. | |
شما همچنین میتوانید روشهای تغییرپذیر و غیرتغییردهنده را با Immer ترکیب کنید. |
|
||
For example, in this version `handleAddTodo` is implemented by mutating the Immer `draft`, while `handleChangeTodo` and `handleDeleteTodo` use the non-mutative `map` and `filter` methods: | ||
برای مثال، در این نسخه تابع `handleAddTodo` با mutate کردن `draft` Immer پیاده سازی شده است، در حالی که توابع `handleChangeTodo` و `handleDeleteTodo` از متدهای non-mutative `map` و `filter` استفاده میکنند: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
برای مثال، در این نسخه تابع `handleAddTodo` با mutate کردن `draft` Immer پیاده سازی شده است، در حالی که توابع `handleChangeTodo` و `handleDeleteTodo` از متدهای non-mutative `map` و `filter` استفاده میکنند: | |
برای مثال، در این نسخه، تابع `handleAddTodo` با تغییر دادن `draft`ِ Immer پیادهسازی شده است، در حالیکه توابع `handleChangeTodo` و `handleDeleteTodo` از متدهای غیرتغییردهندهٔ `map` و `filter` استفاده میکنند: |
This pull request includes the translation of the updating-arrays-in-state page.
Please let me know if you have any suggestions for improvement.
Thanks.