`) has to line up. Otherwise, toggling `isActive` would recreate the whole tree below and [reset its state.](/learn/preserving-and-resetting-state) This is why, if a similar JSX tree gets returned in both cases, it is better to write them as a single piece of JSX.
+بخاطر داشته باشید که اگر دو قطعه مختلف JSX یک درخت مشابه را توصیف کنند، تودرتویی آنها (اولین `
` → اولین `
![]()
`) باید منظم باشد.درغیراینصورت، تغییر وضعیت `isActive` باعث بازسازی کل زیردرخت شده و [state آن را بازنشانی می کند.](/learn/preserving-and-resetting-state) به این دلیل است که اگر یک درخت JSX مشابه در هردو حالت بازگردانده شود، بهتر است آنها را به عنوان یک قطعه JSX واحد بنویسید.
-#### Profile editor {/*profile-editor*/}
+#### ویرایشگر پروفایل {/*profile-editor*/}
-Here is a small form implemented with plain JavaScript and DOM. Play with it to understand its behavior:
+در زیر یک فرم کوچک با استفاده از جاوااسکریپت خام و DOM پیاده سازی شده است. با آن بازی کنید تا رفتار آن را درک کنید:
@@ -800,11 +800,11 @@ label { display: block; margin-bottom: 20px; }
-This form switches between two modes: in the editing mode, you see the inputs, and in the viewing mode, you only see the result. The button label changes between "Edit" and "Save" depending on the mode you're in. When you change the inputs, the welcome message at the bottom updates in real time.
+این فرم بین دو حالت جابجا میشود: در حالت ویرایش، ورودیها را مشاهده میکنید و در حالت مشاهده، تنها نتیجه را مشاهده میکنید. عنوان دکمه براساس حالتی که در آن قرار دارید بین "Edit" و "Save" تغییر می کند. وقتی که ورودی ها را تغییر می دهید، پیام خوشامدگویی در پایین، به شکل بلادرنگ بروزرسانی می شود.
-Your task is to reimplement it in React in the sandbox below. For your convenience, the markup was already converted to JSX, but you'll need to make it show and hide the inputs like the original does.
+وظیفه شما این است که آن را در محیط تستی ری اکت زیر دوباره پیاده سازی کنید. برای راحتی شما، نشانه گذاری از قبل به JSX تبدیل شده است، اما شما باید ورودی ها را مانند نسخه اصلی نمایش داده و پنهان کنید.
-Make sure that it updates the text at the bottom, too!
+مطمئن شوید که متن پایین را هم بروزرسانی کند!
@@ -839,9 +839,9 @@ label { display: block; margin-bottom: 20px; }
-You will need two state variables to hold the input values: `firstName` and `lastName`. You're also going to need an `isEditing` state variable that holds whether to display the inputs or not. You should _not_ need a `fullName` variable because the full name can always be calculated from the `firstName` and the `lastName`.
+شما به دو متغیر state برای نگهداری مقادیر ورودی نیاز خواهی داشت: `firstName` و `lastName`. همچنین شما به یک متغیر state `isEditing` نیاز دارید که نگهدارنده وضعیت نمایش یا عدم نمایش ورودی ها باشد. شما _نباید_ به یک متغیر `fullName` نیاز داشته باشید چرا که نام کامل همیشه از `firstName` و `lastName` به دست می آید.
-Finally, you should use [conditional rendering](/learn/conditional-rendering) to show or hide the inputs depending on `isEditing`.
+درنهایت، شما باید از [رندر کردن شرطی](/learn/conditional-rendering) برای نمایش یا مخفی کردن ورودی ها براساس `isEditing` استفاده کنید.
@@ -899,13 +899,13 @@ label { display: block; margin-bottom: 20px; }
-Compare this solution to the original imperative code. How are they different?
+این راه حل را با کد دستوری اصلی مقایسه کنید. چقدر تفاوت دارند؟
-#### Refactor the imperative solution without React {/*refactor-the-imperative-solution-without-react*/}
+#### راه حل دستوری را بدون استفاده از ری اکت بازسازی کنید {/*refactor-the-imperative-solution-without-react*/}
-Here is the original sandbox from the previous challenge, written imperatively without React:
+در زیر محیط تستی اصلی از چالش قبلی آورده شده، که به شکل دستوری و بدون ری اکت نوشته شده است:
@@ -1002,9 +1002,9 @@ label { display: block; margin-bottom: 20px; }
-Imagine React didn't exist. Can you refactor this code in a way that makes the logic less fragile and more similar to the React version? What would it look like if the state was explicit, like in React?
+تصور کنید ری اکت وجود نداشت. آیا می توانید این کد را به گونه ای بازسازی کنید که منطق با حساسیت کمتر و بیشتر شبیه نسخه ری اکت شود؟اگر مانند ری اکت state به صورت صریح باشد، به چه شکل خواهد بود؟
-If you're struggling to think where to start, the stub below already has most of the structure in place. If you start here, fill in the missing logic in the `updateDOM` function. (Refer to the original code where needed.)
+اگر برای شروع درحال تقلا هستید، بخش زیر هم اکنون بیشتر ساختار را در خود جای داده است. اگر از اینجا شروع می کنید، منطق جاافتاده در تابع `updateDOM` را تکمیل کنید. (برای اطلاعات بیشتر به کد اصلی مراجعه کنید.)
@@ -1044,12 +1044,12 @@ function setIsEditing(value) {
function updateDOM() {
if (isEditing) {
editButton.textContent = 'Save Profile';
- // TODO: show inputs, hide content
+ // TODO: نمایش ورودی ها، مخفی کردن محتوا
} else {
editButton.textContent = 'Edit Profile';
- // TODO: hide inputs, show content
+ // TODO: نمایش محتوا، مخفی کردن ورودی ها
}
- // TODO: update text labels
+ // TODO: بروزسانی عناوین متن
}
function hide(el) {
@@ -1111,7 +1111,7 @@ label { display: block; margin-bottom: 20px; }
-The missing logic included toggling the display of inputs and content, and updating the labels:
+منطق جاافتاده شامل تغییر نمایش ورودی ها و محتوا، و بروزرسانی عناوین بود:
@@ -1228,7 +1228,8 @@ label { display: block; margin-bottom: 20px; }
-The `updateDOM` function you wrote shows what React does under the hood when you set the state. (However, React also avoids touching the DOM for properties that have not changed since the last time they were set.)
+تابع `updateDOM` که نوشتید نشان می دهد وقتی که شما state را ست می کنید ری اکت در پس زمینه چه کاری انجام می دهد. (اگرچه، ری اکت از تغییر prop های DOM که پس از آخرین مرتبه ست شدن تغییری نداشته اند اجتناب می کند.)
+