You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/state-a-components-memory.md
+39-40Lines changed: 39 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,25 @@
1
1
---
2
-
title: "State: A Component's Memory"
2
+
title: "স্টেট: কম্পোনেন্ট এর মেমোরি"
3
3
---
4
4
5
5
<Intro>
6
6
7
-
Components often need to change what's on the screen as a result of an interaction. Typing into the form should update the input field, clicking "next" on an image carousel should change which image is displayed, clicking "buy" should put a product in the shopping cart. Components need to "remember" things: the current input value, the current image, the shopping cart. In React, this kind of component-specific memory is called *state*.
7
+
ইন্টারেকশনের ফলে প্রায়ই কম্পোনেন্ট কে স্ক্রিনে যা আছে তা পরিবর্তন করতে হয়। ফর্মে টাইপ করলে ইনপুট ফিল্ড আপডেট হয়ে যাওয়া উচিত, ইমেজ ক্যারাউজেলে এর "next" এ ক্লিক করলে ডিসপ্লের ইমেজ চেঞ্জ হওয়া উচিত, "buy" এ ক্লিক করলে প্রোডাক্ট শপিং কার্ট এ যাওয়া উচিত। কম্পোনেন্ট এর কিছু জিনিস মনে রাখা উচিত, যেমন: বর্তমান ইনপুট ভেলু, বর্তমান ইমেজ, শপিং কার্ট। React এর এমন কম্পোনেন্ট-ভিত্তিক মেমোরি কে *state* বলে।
8
8
9
9
</Intro>
10
10
11
11
<YouWillLearn>
12
12
13
-
*How to add a state variable with the [`useState`](/reference/react/useState)Hook
14
-
*What pair of values the `useState` Hook returns
15
-
*How to add more than one state variable
16
-
*Why state is called local
13
+
*[`useState`](/reference/react/useState)দিয়ে কিভাবে একটি স্টেট ভেরিয়েবল তৈরি করা যায়
14
+
*`useState` হুক কোন দুইটি ভেরিয়েবল রিটার্ন করে
15
+
*কিভাবে একাধিক স্টেট ভেরিয়েবল তৈরি করতে হয়
16
+
*স্টেট কে কেন লোকাল বলা হয়
17
17
18
18
</YouWillLearn>
19
19
20
-
## When a regular variable isn’t enough {/*when-a-regular-variable-isnt-enough*/}
20
+
## যখন রেগুলার ভেরিয়েবল যথেষ্ট নয় {/*when-a-regular-variable-isnt-enough*/}
21
21
22
-
Here's a component that renders a sculpture image. Clicking the "Next" button should show the next sculpture by changing the `index`to `1`, then`2`, and so on. However, this**won't work** (you can try it!):
22
+
নিচের কম্পোনেন্টটি একটি ভাস্কর্যের ছবি প্রদর্শন করে। "Next" বাটন এ ক্লিক করলে `index`এর ভেলু `1`, এরপর`2` এবং এভাবে পরিবর্তন হয়ে পরের ভাস্কর্যের ছবি দেখানো উচিত। কিন্তু, এটা**কাজ করবেনা** (আপনি চেষ্টা করে দেখতে পারেন!):
23
23
24
24
<Sandpack>
25
25
@@ -151,54 +151,54 @@ button {
151
151
152
152
</Sandpack>
153
153
154
-
The `handleClick`event handler is updating a local variable, `index`. But two things prevent that change from being visible:
154
+
`handleClick`ইভেন্ট হ্যান্ডলারটি লোকাল ভেরিয়েবল `index` কে আপডেট করছে। তবে, দুটি বিষয় এই পরিবর্তন দেখতে বাধা তৈরি করছে।
155
155
156
-
1.**Local variables don't persist between renders.**When React renders this component a second time, it renders it from scratch—it doesn't consider any changes to the local variables.
157
-
2.**Changes to local variables won't trigger renders.**React doesn't realize it needs to render the component again with the new data.
156
+
1.**লোকাল ভেরিবলগুলো রেন্ডারগুলির মধ্যে স্থায়ী হয় না।**যখন React কোন কম্পোনেন্ট দ্বিতীয়বার রেন্ডার করে, তখন এটি সম্পূর্ণরূপে নতুন করে রেন্ডার করে—এটি লোকাল ভেরিয়েবলগুলিতে কোনও পরিবর্তন বিবেচনা করে না।
157
+
2.**লোকাল ভেরিয়েবলগুলিতে পরিবর্তন রেন্ডারগুলি ট্রিগার করে না।**নতুন ডেটার জন্যে React তার কম্পোনেন্ট কে নতুন করে রেন্ডার করার প্রয়োজন মনে করে না।
158
158
159
-
To update a component with new data, two things need to happen:
159
+
একটি কম্পোনেন্টকে নতুন ডেটা দিয়ে আপডেট করতে, দুটি বিষয় হতে হবে:
160
160
161
-
1.**Retain**the data between renders.
162
-
2.**Trigger** React to render the component with new data (re-rendering).
161
+
1.রেন্ডার এর মধ্যে ডাটা **Retain**করা।
162
+
2.কম্পোনেন্টকে নতুন ডাটা দিয়ে রেন্ডার করতে রিয়েক্ট কে **Trigger** করা। (রি-রেন্ডারিং)
163
163
164
-
The [`useState`](/reference/react/useState)Hook provides those two things:
164
+
[`useState`](/reference/react/useState)হুক আপনাকে নিচের দুটি জিনিস দেয়:
165
165
166
-
1.A**state variable**to retain the data between renders.
167
-
2.A**state setter function**to update the variable and trigger React to render the component again.
166
+
1.একটি**স্টেট ভেরিয়েবল**যা রি-রেন্ডারের মধ্যে ডাটা মনে রাখে।
167
+
2.একটি**স্টেট setter ফাংশন**যা দিয়ে ভেরিয়েবল আপডেট করা যায় এবং রিয়েক্ট কে ট্রিগার করে কম্পোনেন্টকে আবার রেন্ডার করতে।
168
168
169
-
## Adding a state variable {/*adding-a-state-variable*/}
169
+
## স্টেট ভেরিয়েবল তৈরি করা {/*adding-a-state-variable*/}
170
170
171
-
To add a state variable, import `useState`from React at the top of the file:
171
+
স্টেট ভেরিয়েবল তৈরি করতে হলে,রিয়েক্ট থেকে ফাইলের উপরে `useState`ইমপোর্ট করতে হবে :
172
172
173
173
```js
174
174
import { useState } from'react';
175
175
```
176
176
177
-
Then, replace this line:
177
+
এরপর, নিচের লাইন টা পরিবর্তন করে:
178
178
179
179
```js
180
180
let index =0;
181
181
```
182
182
183
-
with
183
+
নিচের মতো করে নিন
184
184
185
185
```js
186
186
const [index, setIndex] =useState(0);
187
187
```
188
188
189
-
`index`is a state variable and `setIndex`is the setter function.
189
+
`index`একটি স্টেট ভেরিয়েবল এবং `setIndex`হচ্ছে setter ফাংশন।
190
190
191
191
> The `[` and `]` syntax here is called [array destructuring](https://javascript.info/destructuring-assignment) and it lets you read values from an array. The array returned by `useState` always has exactly two items.
192
192
193
-
This is how they work together in `handleClick`:
193
+
এইভাবে তারা `handleClick` এ একসাথে কাজ করে :
194
194
195
195
```js
196
196
functionhandleClick() {
197
197
setIndex(index +1);
198
198
}
199
199
```
200
200
201
-
Now clicking the "Next" button switches the current sculpture:
201
+
এখন "Next" বাটনে ক্লিক করলে বর্তমান ভাস্কর্যটি পরিবর্তন হয়:
202
202
203
203
<Sandpack>
204
204
@@ -331,18 +331,17 @@ button {
331
331
332
332
</Sandpack>
333
333
334
-
### Meet your first Hook {/*meet-your-first-hook*/}
334
+
### আপনার প্রথম হুকের সাথে পরিচয় {/*meet-your-first-hook*/}
335
335
336
-
In React, `useState`, as well as any other function starting with "`use`", is called a Hook.
336
+
রিয়েক্ট এ, `useState`, এবং অন্য যেকোনো ফাংশন যার শুরু "`use`" দিয়ে তাদেরকে হুক বলা হয়।
337
337
338
-
*Hooks*are special functions that are only available while React is [rendering](/learn/render-and-commit#step-1-trigger-a-render)(which we'll get into in more detail on the next page). They let you "hook into" different React features.
338
+
*Hooks*এক ধরনের স্পেশাল ফাংশন যা শুধু React এর [রেন্ডারিং](/learn/render-and-commit#step-1-trigger-a-render)এর সময় কাজ করে (রেন্ডারিং নিয়ে পরের পাতায় আমরা আরো বিস্তারিত জানব)। এরা রিয়েক্ট এর বিভিন্ন ফিচারকে "আঁকরে ধরতে" সাহায্য করে।
339
339
340
-
State is just one of those features, but you will meet the other Hooks later.
340
+
স্টেট এদের মধ্যে একটি ফিচার, কিন্তু অন্যান্য হুক নিয়ে আমরা পরবর্তীতে জানব।
341
341
342
342
<Pitfall>
343
343
344
-
**Hooks—functions starting with `use`—can only be called at the top level of your components or [your own Hooks.](/learn/reusing-logic-with-custom-hooks)** You can't call Hooks inside conditions, loops, or other nested functions. Hooks are functions, but it's helpful to think of them as unconditional declarations about your component's needs. You "use" React features at the top of your component similar to how you "import" modules at the top of your file.
345
-
344
+
**`use` দিয়ে শুরু হয়েছে এমন Hooks—ফাংশনগুলি—শুধুমাত্র আপনার কম্পোনেন্টগুলির শীর্ষ স্তরে বা [আপনার নিজস্ব Hooks-এ](/learn/reusing-logic-with-custom-hooks) কল করা যায়** আপনি কন্ডিশন, লুপ, বা অন্যান্য নেস্টেড ফাংশনের মধ্যে Hooks কল করতে পারবেন না। Hooks হলো ফাংশন, কিন্তু এদের অনেকটা কম্পোনেন্টের নিশর্ত প্রয়োজন হিসাবে ভাবতে পারেন। এইখানে আপনি কম্পোনেন্টের এর উপরে React এর ফিচার "ব্যবহার" করেন অনেকটা যেভাবে ফাইলের উপরে "import" ব্যবহার করে মডিউল লোড করেন।
346
345
</Pitfall>
347
346
348
347
### Anatomy of `useState` {/*anatomy-of-usestate*/}
@@ -353,7 +352,7 @@ When you call [`useState`](/reference/react/useState), you are telling React tha
353
352
const [index, setIndex] =useState(0);
354
353
```
355
354
356
-
In this case, you want React to remember `index`.
355
+
এই ক্ষেত্রে আপনি চাচ্ছেন রিয়েক্ট `index` টি মনে রাখুক.
3.**Your component's second render.** React still sees `useState(0)`, but because React *remembers* that you set `index` to `1`, it returns `[1, setIndex]` instead.
380
379
4. And so on!
381
380
382
-
## Giving a component multiple state variables {/*giving-a-component-multiple-state-variables*/}
381
+
## কম্পোনেন্ট এ একাধিক স্টেট ভেরিয়েবল ব্যবহার করা {/*giving-a-component-multiple-state-variables*/}
383
382
384
-
You can have as many state variables of as many types as you like in one component. This component has two state variables, a number`index`and a boolean`showMore`that's toggled when you click "Show details":
383
+
একটি কম্পোনেন্ট এ আপনি যত খুশি তত ধরনের ষ্টেট ভেরিয়েবল রাখতে পারেন। এই কম্পোনেন্ট এর দুটি স্টেট ভেরিয়েবল আছে, একটি নাম্বার`index`এবং একটি বুলিয়ান`showMore`যা Toggle করা হয় যখন আপনি "Show details" এ ক্লিক করেন :
385
384
386
385
<Sandpack>
387
386
@@ -524,7 +523,7 @@ It is a good idea to have multiple state variables if their state is unrelated,
524
523
525
524
<DeepDive>
526
525
527
-
#### How does React know which state to return? {/*how-does-react-know-which-state-to-return*/}
526
+
#### রিয়েক্ট কিভাবে জানে কোন স্টেট রিটার্ন করতে হবে? {/*how-does-react-know-which-state-to-return*/}
528
527
529
528
You might have noticed that the `useState` call does not receive any information about *which* state variable it refers to. There is no "identifier" that is passed to `useState`, so how does it know which of the state variables to return? Does it rely on some magic like parsing your functions? The answer is no.
530
529
@@ -913,7 +912,7 @@ What if you wanted both galleries to keep their states in sync? The right way to
913
912
914
913
<Challenges>
915
914
916
-
#### Complete the gallery {/*complete-the-gallery*/}
915
+
#### গ্যালারিটি সম্পূর্ণ করুণ {/*complete-the-gallery*/}
917
916
918
917
When you press "Next" on the last sculpture, the code crashes. Fix the logic to prevent the crash. You may do this by adding extra logic to event handler or by disabling the button when the action is not possible.
919
918
@@ -1325,7 +1324,7 @@ h1 { margin-top: 10px; }
1325
1324
1326
1325
</Solution>
1327
1326
1328
-
#### Fix a crash {/*fix-a-crash*/}
1327
+
#### ক্র্যাশ ঠিক করুন {/*fix-a-crash*/}
1329
1328
1330
1329
Here is a small form that is supposed to let the user leave some feedback. When the feedback is submitted, it's supposed to display a thank-you message. However, it crashes with an error message saying "Rendered fewer hooks than expected". Can you spot the mistake and fix it?
1331
1330
@@ -1450,13 +1449,13 @@ If your linter is [configured for React](/learn/editor-setup#linting), you shoul
1450
1449
1451
1450
</Solution>
1452
1451
1453
-
#### Remove unnecessary state {/*remove-unnecessary-state*/}
1452
+
#### অপ্রয়োজনীয় স্টেট বাদ দিন {/*remove-unnecessary-state*/}
1454
1453
1455
1454
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, !".
1456
1455
1457
1456
To fix this code, remove the unnecessary state variable. (We will discuss about [why this didn't work](/learn/state-as-a-snapshot) later.)
1458
1457
1459
-
Can you explain why this state variable was unnecessary?
1458
+
আপনি ব্যাখ্যা করতে পারবেন কেন এই স্টেট ভেরিয়েবলটি অপ্রয়োজনীয়?
1460
1459
1461
1460
<Sandpack>
1462
1461
@@ -1483,7 +1482,7 @@ export default function FeedbackForm() {
1483
1482
1484
1483
<Solution>
1485
1484
1486
-
Here is a fixed version that uses a regular `name`variable declared in the function that needs it:
1485
+
এখানে একটি ঠিক ভার্সন দেওয়া হলো যা ফাংশনের এর মধ্যে প্রয়োজনীয় রেগুলার `name`ভেরিয়েবল ব্যবহার করে:
1487
1486
1488
1487
<Sandpack>
1489
1488
@@ -1504,7 +1503,7 @@ export default function FeedbackForm() {
1504
1503
1505
1504
</Sandpack>
1506
1505
1507
-
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.
1506
+
স্টেট ভেরিয়েবল শুধু রি-রেন্ডার এর মাঝে তথ্য মনে রাখার জন্য দরকার। যেকোনো একই ইভেন্ট হ্যান্ডলার এর মধ্যে রেগুলার ভেরিয়েবলই যথেষ্ট। যেখানে রেগুলার ভেরিয়েবল যথেষ্ট সেখানে স্টেট ভেরিবল ব্যবহার করা উচিত না।
0 commit comments