Skip to content

Commit 759c23b

Browse files
includes: state-a-component's-memory
1 parent dc5a467 commit 759c23b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/content/learn/state-a-components-memory.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,8 +1430,7 @@ export default function FeedbackForm() {
14301430
```
14311431

14321432
</Sandpack>
1433-
1434-
Remember, Hooks must be called unconditionally and always in the same order!
1433+
به یاد داشته باشید٬ هوک ها باید بدون قید و شرط و. همیشه به یک ترتیب فراخوانده شوند.
14351434

14361435
You could also remove the unnecessary `else` branch to reduce the nesting. However, it's still important that all calls to Hooks happen *before* the first `return`.
14371436

@@ -1476,12 +1475,11 @@ If your linter is [configured for React](/learn/editor-setup#linting), you shoul
14761475

14771476
#### Remove unnecessary state {/*remove-unnecessary-state*/}
14781477

1479-
When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason it always shows "Hello, !".
1480-
1481-
To fix this code, remove the unnecessary state variable. (We will discuss about [why this didn't work](/learn/state-as-a-snapshot) later.)
1478+
سعی کنید فراخوانی دوم `useState` را پس از شرط `if` قرار دهید و مشاهده کنید که چگونه این باعث شکست آن می‌شود.
14821479

1483-
Can you explain why this state variable was unnecessary?
1480+
اگر لینتر شما [برای React پیکربندی شده است](/learn/editor-setup#linting)، باید هنگامی که مانند این اشتباه را انجام می‌دهید، یک خطای لینت ببینید. اگر هنگام تست کد خراب را در محلی اجرا می‌کنید و خطایی نمی‌بینید، باید برای پروژه خود لینتینگ را پیکربندی کنید.
14841481

1482+
آیا میتوانید توضیح دهید چرا این متغیر استیت الزامی نیست؟
14851483
<Sandpack>
14861484

14871485
```js
@@ -1530,7 +1528,8 @@ export default function FeedbackForm() {
15301528

15311529
</Sandpack>
15321530

1533-
A state variable is only necessary to keep information between re-renders of a component. Within a single event handler, a regular variable will do fine. Don't introduce state variables when a regular variable works well.
1531+
یک متغیر وضعیت فقط زمانی ضروری است که بخواهید اطلاعات را بین بازنمایی‌های مجدد یک کامپوننت نگه دارید. در داخل یک کنترل‌کننده رویداد - یک متغیر معمولی کافی است. زمانی که یک متغیر معمولی به خوبی کار می‌کند، متغیرهای استیت را معرفی نکنید.
1532+
15341533

15351534
</Solution>
15361535

0 commit comments

Comments
 (0)