Skip to content

Commit 859a890

Browse files
authored
Merge pull request #18 from shakib609/keeping-components-pure
Translate - Keeping Components Pure
2 parents 450e328 + 8669ddf commit 859a890

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

src/content/learn/keeping-components-pure.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
---
2-
title: Keeping Components Pure
2+
title: কম্পোনেন্টকে বিশুদ্ধ রাখা
33
---
44

55
<Intro>
66

7-
Some JavaScript functions are *pure.* Pure functions only perform a calculation and nothing more. By strictly only writing your components as pure functions, you can avoid an entire class of baffling bugs and unpredictable behavior as your codebase grows. To get these benefits, though, there are a few rules you must follow.
7+
কিছু জাভাস্ক্রিপ্ট ফাংশন *বিশুদ্ধ।* বিশুদ্ধ ফাংশনগুলো শুধুমাত্র একটি হিসাব করে, অন্য কিছু নয়। আপনি যথাযথভাবে আপনার কম্পোনেন্টগুলোকে বিশুদ্ধ ফাংশন হিসাবে লিখার মাধ্যমে আপনার কোডবেইজ বাড়ার সাথে সাথে অনেক বিভ্রান্তিকর বাগ এবং অনিশ্চিত আচরণ এড়িয়ে যেতে পারবেন। এই সুবিধাগুলো পাওয়ার জন্য আপনার নির্দিষ্ট কিছু নিয়ম মেনে চলতে হবে।
88

99
</Intro>
1010

1111
<YouWillLearn>
1212

13-
* What purity is and how it helps you avoid bugs
14-
* How to keep components pure by keeping changes out of the render phase
15-
* How to use Strict Mode to find mistakes in your components
13+
* বিশুদ্ধতা কি এবং এটি কিভাবে আপনাকে বাগ এড়িয়ে যেতে সাহায্য করে
14+
* কম্পোনেন্টকে কিভাবে বিশুদ্ধ রাখা যায় পরিবর্তনগুলোকে রেন্ডারের ধাপের বাইরে রেখে
15+
* কিভাবে Strict Mode ব্যবহার করে আপনার কম্পোনেন্টের ভুলগুলো ধরতে পারবেন
1616

1717
</YouWillLearn>
1818

19-
## Purity: Components as formulas {/*purity-components-as-formulas*/}
19+
## বিশুদ্ধতাঃ সূত্র হিসেবে কম্পোনেন্ট {/*purity-components-as-formulas*/}
2020

21-
In computer science (and especially the world of functional programming), [a pure function](https://wikipedia.org/wiki/Pure_function) is a function with the following characteristics:
21+
কম্পিউটার সায়েন্সে (বিশেষ করে ফাংশনাল প্রোগ্রামিং-এ), [একটি বিশুদ্ধ ফাংশন](https://wikipedia.org/wiki/Pure_function) হল এমন একটি ফাংশন যার নিচের বৈশিষ্ট্যগুলো রয়েছেঃ
2222

23-
* **It minds its own business.** It does not change any objects or variables that existed before it was called.
24-
* **Same inputs, same output.** Given the same inputs, a pure function should always return the same result.
23+
* **নিজের কাজ নিয়েই ব্যস্ত।** এটি কল করার আগের কোন অবজেক্ট বা ভ্যারিয়েবল পরিবর্তন করেনা।
24+
* **একই ইনপুট, একই আউটপুট।** একই ইনপুটের জন্য একটি বিশুদ্ধ ফাংশন সবসময় একই আউটপুট রিটার্ন করে।
2525

26-
You might already be familiar with one example of pure functions: formulas in math.
26+
আপনি হয়তো এরই মধ্যে বিশুদ্ধ ফাংশনের একটি উদাহরণের সাথে পরিচিতঃ গণিতের সূত্র।
2727

28-
Consider this math formula: <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math>.
28+
এই গণিতের সূত্রটিই ধরুনঃ <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math>.
2929

30-
If <Math><MathI>x</MathI> = 2</Math> then <Math><MathI>y</MathI> = 4</Math>. Always.
30+
যদি <Math><MathI>x</MathI> = 2</Math> হয়, তাহলে <Math><MathI>y</MathI> = 4</Math> হবে। সবসময়।
3131

32-
If <Math><MathI>x</MathI> = 3</Math> then <Math><MathI>y</MathI> = 6</Math>. Always.
32+
যদি <Math><MathI>x</MathI> = 3</Math> হয়, তাহলে <Math><MathI>y</MathI> = 6</Math> হবে। সবসময়।
3333

34-
If <Math><MathI>x</MathI> = 3</Math>, <MathI>y</MathI> won't sometimes be <Math>9</Math> or <Math>–1</Math> or <Math>2.5</Math> depending on the time of day or the state of the stock market.
34+
যদি <Math><MathI>x</MathI> = 3</Math> হয়, তাহলে <MathI>y</MathI> কখনো কখনো <Math>9</Math> অথবা <Math>–1</Math> অথবা <Math>2.5</Math> হবেনা, দিনের কোন সময় বা স্টক মার্কেটের অবস্থার উপর নির্ভর করে।
3535

36-
If <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math> and <Math><MathI>x</MathI> = 3</Math>, <MathI>y</MathI> will _always_ be <Math>6</Math>.
36+
যদি <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math> এবং <Math><MathI>x</MathI> = 3</Math> হয়, <MathI>y</MathI> তাহলে _সবসময়_ <Math>6</Math> হবে।
3737

38-
If we made this into a JavaScript function, it would look like this:
38+
আমরা যদি এটিকে একটি জাভাস্ক্রিপ্ট ফাংশনে রুপ দেই, তাহলে এটি এমন দেখাবেঃ
3939

4040
```js
4141
function double(number) {
4242
return 2 * number;
4343
}
4444
```
4545

46-
In the above example, `double` is a **pure function.** If you pass it `3`, it will return `6`. Always.
46+
উপরের উদাহরণে, `double` একটি **বিশুদ্ধ ফাংশন।** আপনি যদি এটিতে `3` পাস করেন এটি `6` রিটার্ন করবে। সবসময়।
4747

48-
React is designed around this concept. **React assumes that every component you write is a pure function.** This means that React components you write must always return the same JSX given the same inputs:
48+
React এই ধারণার উপর ভিত্তি করেই তৈরি করা হয়েছে। **React ধরে নেয় আপনার লেখা সব কম্পোনেন্টই বিশুদ্ধ ফাংশন।** তার মানে আপনার লিখা React কম্পোনেন্টগুলোর অবশ্যই একই ইনপুটের জন্য একই JSX রিটার্ন করতে হবেঃ
4949

5050
<Sandpack>
5151

@@ -75,21 +75,21 @@ export default function App() {
7575

7676
</Sandpack>
7777

78-
When you pass `drinkers={2}` to `Recipe`, it will return JSX containing `2 cups of water`. Always.
78+
আপনি যখন `Recipe` তে `drinkers={2}` পাস করবেন, এটি JSX রিটার্ন করবে যাতে `2 cups of water` থাকবে। সবসময়।
7979

80-
If you pass `drinkers={4}`, it will return JSX containing `4 cups of water`. Always.
80+
যদি আপনি `drinkers={4}` পাস করেন, এটি JSX রিটার্ন করবে যাতে `4 cups of water` থাকবে। সবসময়।
8181

82-
Just like a math formula.
82+
ঠিক একটি গণিতের সূত্রের মত।
8383

84-
You could think of your components as recipes: if you follow them and don't introduce new ingredients during the cooking process, you will get the same dish every time. That "dish" is the JSX that the component serves to React to [render.](/learn/render-and-commit)
84+
আপনি আপনার কম্পোনেন্টকে একটি রেসিপি হিসেবে চিন্তা করতে পারেনঃ যদি আপনি এগুলো অনুসরণ করেন এবং রান্নার সময়ে নতুন কোন উপাদান না আনেন তাহলে আপনি সবসময় একই খাবার পাবেন। এই "খাবার" হল JSX যা আপনার কম্পোনেন্ট React কে [রেন্ডার](/learn/render-and-commit) করার জন্য পরিবেশন করে।
8585

8686
<Illustration src="/images/docs/illustrations/i_puritea-recipe.png" alt="A tea recipe for x people: take x cups of water, add x spoons of tea and 0.5x spoons of spices, and 0.5x cups of milk" />
8787

88-
## Side Effects: (un)intended consequences {/*side-effects-unintended-consequences*/}
88+
## পার্শ্ব-প্রতিক্রিয়াঃ (অন)ইচ্ছাকৃত প্রভাব {/*side-effects-unintended-consequences*/}
8989

90-
React's rendering process must always be pure. Components should only *return* their JSX, and not *change* any objects or variables that existed before rendering—that would make them impure!
90+
React এর রেন্ডারিং প্রসেস সবসময় বিশুদ্ধ হতে হবে। কম্পোনেন্টগুলোর শুধুমাত্র তাদের JSX *রিটার্ন* করা উচিত, এবং রেন্ডারিং এর আগের কোন অবজেক্ট বা ভ্যারিয়েবলে পরিবর্তন আনা উচিত নয়-যা এগুলোকে অবিশুদ্ধ করে দেবে!
9191

92-
Here is a component that breaks this rule:
92+
এই কম্পোনেন্টটি এই নিয়ম ভঙ্গ করেঃ
9393

9494
<Sandpack>
9595

@@ -115,11 +115,11 @@ export default function TeaSet() {
115115

116116
</Sandpack>
117117

118-
This component is reading and writing a `guest` variable declared outside of it. This means that **calling this component multiple times will produce different JSX!** And what's more, if _other_ components read `guest`, they will produce different JSX, too, depending on when they were rendered! That's not predictable.
118+
এই কম্পোনেন্টটি এর বাইরে ডিক্লেয়ার করা `guest` ভ্যারিয়েবল রিড এবং রাইট করছে। তার মানে **এই কম্পোনেন্ট বারবার কল করলে ভিন্ন ভিন্ন JSX রিটার্ন করবে!** তার উপর, যদি _অন্য_ কম্পোনেন্ট `guest` থেকে রিড করে, তারাও ভিন্ন JSX রিটার্ন করবে, তারা কখন রেন্ডার হয়েছিল এর উপর ভিত্তি করে! এটি মোটেও অনুমানযোগ্য নয়।
119119

120-
Going back to our formula <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math>, now even if <Math><MathI>x</MathI> = 2</Math>, we cannot trust that <Math><MathI>y</MathI> = 4</Math>. Our tests could fail, our users would be baffled, planes would fall out of the sky—you can see how this would lead to confusing bugs!
120+
আমরা যদি আমাদের সূত্রে ফিরে যাই, <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math>, এখন <Math><MathI>x</MathI> = 2</Math> হওয়ার পরেও, আমরা নিশ্চিত হতে পারবনা <Math><MathI>y</MathI> = 4</Math> হবে। আমাদের টেস্ট ফেইল করতে পারে, আমাদের ইউজার বিস্মিত হতে পারে, প্লেইন আকাশ থেকে পড়ে যেতে পারে-দেখতেই পাচ্ছেন এটি কিভাবে বিভিন্ন বিভ্রান্তিকর বাগ তৈরি করতে পারে!
121121

122-
You can fix this component by [passing `guest` as a prop instead](/learn/passing-props-to-a-component):
122+
আপনি এই কম্পোনেন্টে [`guest` একটি prop হিসেবে পাস করার মাধ্যমে](/learn/passing-props-to-a-component) এটি ঠিক করতে পারেনঃ
123123

124124
<Sandpack>
125125

@@ -141,9 +141,9 @@ export default function TeaSet() {
141141

142142
</Sandpack>
143143

144-
Now your component is pure, as the JSX it returns only depends on the `guest` prop.
144+
এখন আপনার কম্পোনেন্টটি বিশুদ্ধ, যেহেতু এর দ্বারা রিটার্নকৃত JSX শুধুমাত্র `guest` prop এর উপর নির্ভর করে।
145145

146-
In general, you should not expect your components to be rendered in any particular order. It doesn't matter if you call <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math> before or after <Math><MathI>y</MathI> = 5<MathI>x</MathI></Math>: both formulas will resolve independently of each other. In the same way, each component should only "think for itself", and not attempt to coordinate with or depend upon others during rendering. Rendering is like a school exam: each component should calculate JSX on their own!
146+
সাধারণত, আপনার কম্পোনেন্টকে নির্দিষ্ট কোন ক্রমে রেন্ডার করতে হবে এমন আশা করা উচিত নয়। এটি কোন ব্যাপার না আপনি <Math><MathI>y</MathI> = 2<MathI>x</MathI></Math> এর আগে অথবা পরে <Math><MathI>y</MathI> = 5<MathI>x</MathI></Math> কল করলেনঃ উভয় সূত্রই স্বাধীনভাবে সমাধান হবে। একইভাবে, প্রতিটা ক্মপোনেন্টেরই "নিজের জন্য চিন্তা করা" উচিত, এবং রেন্ডারিং এর সময় অন্যের সাথে সমন্বয়ের চেষ্টা অথবা অন্যের উপর নির্ভর করা উচিত নয়। রেন্ডারিং হল স্কুলের পরীক্ষার মতঃ প্রতিটা কম্পোনেন্টেরই তাদের নিজেদের JSX হিসাব করা উচিত!
147147

148148
<DeepDive>
149149

src/sidebarLearn.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"path": "/learn/rendering-lists"
8585
},
8686
{
87-
"title": "Keeping Components Pure",
87+
"title": "কম্পোনেন্টকে বিশুদ্ধ রাখা",
8888
"path": "/learn/keeping-components-pure"
8989
},
9090
{

0 commit comments

Comments
 (0)