diff --git a/src/content/learn/conditional-rendering.md b/src/content/learn/conditional-rendering.md index 895d610d3..369064139 100644 --- a/src/content/learn/conditional-rendering.md +++ b/src/content/learn/conditional-rendering.md @@ -1,24 +1,24 @@ --- -title: Conditional Rendering +title: কন্ডিশনাল বা শর্তসাপেক্ষ রেন্ডারিং --- -Your components will often need to display different things depending on different conditions. In React, you can conditionally render JSX using JavaScript syntax like `if` statements, `&&`, and `? :` operators. +আপনার কম্পোনেন্টগুলো বিভিন্ন শর্তের ওপর ভিত্তি করে বিভিন্ন কিছু প্রদর্শন করতে পারে। React-এ, `if` স্টেটমেন্ট, `&&`, এবং `? :` অপারেটরের মতো জাভাস্ক্রিপ্ট সিনট্যাক্স ব্যবহার করে JSX শর্তানুযায়ী রেন্ডার করতে পারেন। -* How to return different JSX depending on a condition -* How to conditionally include or exclude a piece of JSX -* Common conditional syntax shortcuts you’ll encounter in React codebases +* কিভাবে শর্তানুযায়ী ভিন্ন JSX রিটার্ন করবেন +* কিভাবে কোনো JSX কে শর্তানুযায়ী অন্তর্ভুক্ত বা বাদ দিবেন +* সাধারণ শর্তগত সিনট্যাক্স শর্টকাটগুলো, যা আপনি React কোডবেসে দেখতে পাবেন ## Conditionally returning JSX {/*conditionally-returning-jsx*/} -Let’s say you have a `PackingList` component rendering several `Item`s, which can be marked as packed or not: +ধরুন আপনার একটি `PackingList` কম্পোনেন্ট আছে, যা কয়েকটি `Item` রেন্ডার করে, যেগুলোকে প্যাক করা হয়েছে বা হয়নি এমন হিসেবে চিহ্নিত করা যায়: @@ -52,9 +52,9 @@ export default function PackingList() { -Notice that some of the `Item` components have their `isPacked` prop set to `true` instead of `false`. You want to add a checkmark (✔) to packed items if `isPacked={true}`. +দেখুন, কিছু `Item` কম্পোনেন্টে `isPacked` প্রপ `true` সেট করা হয়েছে, আর কিছুতে `false`। আপনি প্যাক করা আইটেমগুলোতে একটি চেকমার্ক (✅) যোগ করতে চান যদি `isPacked={true}` হয়। -You can write this as an [`if`/`else` statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else) like so: +এটি আপনি [`if`/`else` statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else) স্টেটমেন্ট দিয়ে লিখতে পারেন, যেমন: ```js if (isPacked) { @@ -63,7 +63,7 @@ if (isPacked) { return
  • {name}
  • ; ``` -If the `isPacked` prop is `true`, this code **returns a different JSX tree.** With this change, some of the items get a checkmark at the end: +যদি `isPacked` প্রপ `true` হয়, এই কোড **একটি ভিন্ন JSX ট্রি রিটার্ন করবে**। এই পরিবর্তনের মাধ্যমে কিছু আইটেমের শেষে একটি চেকমার্ক যোগ হবে। @@ -100,13 +100,13 @@ export default function PackingList() { -Try editing what gets returned in either case, and see how the result changes! +যেকোনো ক্ষেত্রে কী রিটার্ন করা হচ্ছে তা এডিট করে দেখুন, এবং ফলাফল কিভাবে পরিবর্তিত হচ্ছে তা লক্ষ্য করুন! -Notice how you're creating branching logic with JavaScript's `if` and `return` statements. In React, control flow (like conditions) is handled by JavaScript. +খেয়াল করুন কিভাবে JavaScript-এর `if` এবং `return` স্টেটমেন্ট ব্যবহার করে আপনি ব্রাঞ্চিং লজিক তৈরি করছেন। React-এ কন্ট্রোল ফ্লো (যেমন কন্ডিশন) JavaScript দ্বারা হ্যান্ডেল করা হয়। -### Conditionally returning nothing with `null` {/*conditionally-returning-nothing-with-null*/} +### ### `null` দিয়ে কিছুই রেন্ডার না করা {/*conditionally-returning-nothing-with-null*/} -In some situations, you won't want to render anything at all. For example, say you don't want to show packed items at all. A component must return something. In this case, you can return `null`: +কিছু পরিস্থিতিতে, আপনি কোনো কিছুই রেন্ডার করতে চাইবেন না। উদাহরণস্বরূপ, ধরুন আপনি প্যাক করা আইটেমগুলো একদম দেখাতে চান না। এমন পরিস্থিতিতে, আপনি `null` রিটার্ন করতে পারেন: ```js if (isPacked) { @@ -115,7 +115,7 @@ if (isPacked) { return
  • {name}
  • ; ``` -If `isPacked` is true, the component will return nothing, `null`. Otherwise, it will return JSX to render. +যদি `isPacked` সত্য হয়, কম্পোনেন্টটি কিছুই রিটার্ন করবে না, অর্থাৎ `null` রিটার্ন করবে। অন্যথায়, এটি JSX রিটার্ন করবে। @@ -152,23 +152,23 @@ export default function PackingList() { -In practice, returning `null` from a component isn't common because it might surprise a developer trying to render it. More often, you would conditionally include or exclude the component in the parent component's JSX. Here's how to do that! +প্রকৃতপক্ষে, কোনো কম্পোনেন্ট থেকে `null` রিটার্ন করা খুব একটা সাধারণ নয়, কারণ এটি রেন্ডার করার চেষ্টা করা কোনো ডেভেলপারকে বিভ্রান্ত করতে পারে। বরং, আপনি সাধারণত মূল কম্পোনেন্টের JSX-এর মধ্যে শর্তানুযায়ী সেই কম্পোনেন্টটি অন্তর্ভুক্ত বা বাদ দেওয়ার চেষ্টা করবেন। এটি কীভাবে করতে হয় তা এখানে দেওয়া হলো! -## Conditionally including JSX {/*conditionally-including-jsx*/} +## শর্ত-সাপেক্ষে JSX অন্তর্ভুক্ত করা {/*conditionally-including-jsx*/} -In the previous example, you controlled which (if any!) JSX tree would be returned by the component. You may already have noticed some duplication in the render output: +উপরের উদাহরণে, আপনি নির্ধারণ করেছেন কোন (যদি থাকে!) JSX ট্রি কম্পোনেন্টটি রিটার্ন করবে। আপনি হয়তো ইতোমধ্যে রেন্ডার আউটপুটে কিছু ডুপ্লিকেশন লক্ষ্য করেছেন: ```js
  • {name} ✔
  • ``` -is very similar to +এটি খুবই অনুরূপ ```js
  • {name}
  • ``` -Both of the conditional branches return `
  • ...
  • `: +উভয় শর্তের ক্ষেত্রেই `
  • ...
  • ` রিটার্ন করছে: ```js if (isPacked) { @@ -177,13 +177,13 @@ if (isPacked) { return
  • {name}
  • ; ``` -While this duplication isn't harmful, it could make your code harder to maintain. What if you want to change the `className`? You'd have to do it in two places in your code! In such a situation, you could conditionally include a little JSX to make your code more [DRY.](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) +যদিও এই পুনরাবৃত্তি ক্ষতিকর নয়, এটি আপনার কোড রক্ষণাবেক্ষণ করা কঠিন করে তুলতে পারে। ধরুন আপনি `className` পরিবর্তন করতে চান? সেক্ষেত্রে আপনাকে কোডের দুই জায়গায় এটি পরিবর্তন করতে হবে! এমন পরিস্থিতিতে, আপনার কোড আরও [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) রাখতে একটু JSX শর্তসাপেক্ষে যুক্ত করতে পারেন। -### Conditional (ternary) operator (`? :`) {/*conditional-ternary-operator--*/} +### শর্তসাপেক্ষ (টার্নারি) অপারেটর (`? :`) {/*conditional-ternary-operator--*/} -JavaScript has a compact syntax for writing a conditional expression -- the [conditional operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) or "ternary operator". +JavaScript-এ শর্তসাপেক্ষ এক্সপ্রেশন লেখার একটি সংক্ষিপ্ত সিনট্যাক্স রয়েছে -- [শর্তসাপেক্ষ অপারেটর](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) বা "টার্নারি অপারেটর"। -Instead of this: +এইভাবে লেখার পরিবর্তে: ```js if (isPacked) { @@ -202,17 +202,17 @@ return ( ); ``` -You can read it as *"if `isPacked` is true, then (`?`) render `name + ' ✔'`, otherwise (`:`) render `name`"*. +আপনি এটা এভাবে পড়তে পারেন *"if `isPacked` is true, then (`?`) render `name + ' ✔'`, otherwise (`:`) render `name`"*. -#### Are these two examples fully equivalent? {/*are-these-two-examples-fully-equivalent*/} +#### এই দুটি উদাহরণ কি পুরোপুরি সমতুল্য? {/*are-these-two-examples-fully-equivalent*/} -If you're coming from an object-oriented programming background, you might assume that the two examples above are subtly different because one of them may create two different "instances" of `
  • `. But JSX elements aren't "instances" because they don't hold any internal state and aren't real DOM nodes. They're lightweight descriptions, like blueprints. So these two examples, in fact, *are* completely equivalent. [Preserving and Resetting State](/learn/preserving-and-resetting-state) goes into detail about how this works. +যদি আপনি অবজেক্ট-ওরিয়েন্টেড প্রোগ্রামিং ব্যাকগ্রাউন্ড থেকে এসে থাকেন, তাহলে হয়তো মনে করবেন যে উপরোক্ত দুটি উদাহরণ সূক্ষ্মভাবে ভিন্ন, কারণ একটি উদাহরণ সম্ভবত `
  • `-এর দুটি আলাদা "ইনস্ট্যান্স" তৈরি করতে পারে। কিন্তু JSX এলিমেন্টগুলো "ইনস্ট্যান্স" নয়, কারণ এগুলো কোনো অভ্যন্তরীণ স্টেট ধারণ করে না এবং প্রকৃত DOM নোডও নয়। এগুলো হালকা বর্ণনা বা ব্লুপ্রিন্টের মতো। সুতরাং, বাস্তবে এই দুটি উদাহরণ সম্পূর্ণ সমতুল্য। [স্টেট সংরক্ষণ ও রিসেট করা](/learn/preserving-and-resetting-state) বিস্তারিতভাবে ব্যাখ্যা করে কিভাবে এটি কাজ করে। -Now let's say you want to wrap the completed item's text into another HTML tag, like `` to strike it out. You can add even more newlines and parentheses so that it's easier to nest more JSX in each of the cases: +এখন ধরুন আপনি সম্পন্ন আইটেমের টেক্সটটিকে অন্য একটি HTML ট্যাগের মধ্যে জড়ানোর জন্য চান, যেমন `` যাতে এটি আউটলাইন করা যায়। আপনি আরও বেশি নিউলাইন এবং বন্ধনী যোগ করতে পারেন যাতে প্রতিটি ক্ষেত্রে আরও JSX নেস্ট করা সহজ হয়। @@ -256,11 +256,11 @@ export default function PackingList() { -This style works well for simple conditions, but use it in moderation. If your components get messy with too much nested conditional markup, consider extracting child components to clean things up. In React, markup is a part of your code, so you can use tools like variables and functions to tidy up complex expressions. +এই স্টাইলটি সহজ শর্তগুলোর জন্য ভালো কাজ করে, তবে এটি সংযতভাবে ব্যবহার করুন। যদি আপনার কম্পোনেন্টগুলো অতিরিক্ত নেস্টেড শর্তযুক্ত মার্কআপ দিয়ে অগোছালো হয়ে যায়, তাহলে শিশু কম্পোনেন্টগুলো আলাদা করে আপনার কোডটিকে পরিষ্কার রাখার কথা ভাবুন। React-এ মার্কআপ কোডেরই অংশ, তাই জটিল এক্সপ্রেশনগুলোকে গোছানোর জন্য আপনি ভ্যারিয়েবল ও ফাংশনের মতো টুল ব্যবহার করতে পারেন। -### Logical AND operator (`&&`) {/*logical-and-operator-*/} +### লজিক্যাল AND অপারেটর (`&&`) {/*logical-and-operator-*/} -Another common shortcut you'll encounter is the [JavaScript logical AND (`&&`) operator.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND#:~:text=The%20logical%20AND%20(%20%26%26%20)%20operator,it%20returns%20a%20Boolean%20value.) Inside React components, it often comes up when you want to render some JSX when the condition is true, **or render nothing otherwise.** With `&&`, you could conditionally render the checkmark only if `isPacked` is `true`: +আরেকটি সাধারণ শর্টকাট হলো [JavaScript লজিক্যাল AND (`&&`) অপারেটর।](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND#:~:text=The%20logical%20AND%20(%20%26%26%20)%20operator,it%20returns%20a%20Boolean%20value.) React কম্পোনেন্টের ভেতরে এটি প্রায়ই ব্যবহৃত হয় যখন আপনি শর্তটি সত্য হলে কিছু JSX রেন্ডার করতে চান, **বা অন্যথায় কিছুই রেন্ডার করতে চান না।** `&&` ব্যবহার করে, আপনি কেবল তখনই চেকমার্কটি শর্তসাপেক্ষে রেন্ডার করতে পারেন যদি `isPacked` `true` হয়: ```js return ( @@ -270,9 +270,9 @@ return ( ); ``` -You can read this as *"if `isPacked`, then (`&&`) render the checkmark, otherwise, render nothing"*. +এটি এভাবে পড়া যায় *"if `isPacked`, then (`&&`) render the checkmark, otherwise, render nothing"*. -Here it is in action: +এখানে এটি কার্যকরভাবে দেখানো হলো: @@ -310,30 +310,30 @@ export default function PackingList() { -A [JavaScript && expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND) returns the value of its right side (in our case, the checkmark) if the left side (our condition) is `true`. But if the condition is `false`, the whole expression becomes `false`. React considers `false` as a "hole" in the JSX tree, just like `null` or `undefined`, and doesn't render anything in its place. +একটি [JavaScript && এক্সপ্রেশন](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND) তার ডান পাশের মানটি (আমাদের ক্ষেত্রে চেকমার্ক) ফেরত দেয় যদি বাম পাশের শর্তটি `true` হয়। কিন্তু যদি শর্তটি `false` হয়, তবে পুরো এক্সপ্রেশনটি `false` হয়ে যায়। React `false`-কে JSX ট্রিতে একটি "ফাঁকা" হিসেবে গণ্য করে, যেমন `null` বা `undefined`, এবং এর স্থানে কিছুই রেন্ডার করে না। -**Don't put numbers on the left side of `&&`.** +**সংখ্যাগুলোকে `&&`-এর বাম পাশে ব্যবহার করবেন না।** -To test the condition, JavaScript converts the left side to a boolean automatically. However, if the left side is `0`, then the whole expression gets that value (`0`), and React will happily render `0` rather than nothing. +শর্ত পরীক্ষা করার জন্য, JavaScript স্বয়ংক্রিয়ভাবে বাম পাশের মানকে একটি বুলিয়ান এ রূপান্তর করে। তবে, যদি বাম পাশের মান `0` হয়, তাহলে পুরো এক্সপ্রেশন `0` মানটি পায়, এবং React এটি কিছু না রেন্ডার করার পরিবর্তে `0` রেন্ডার করবে। -For example, a common mistake is to write code like `messageCount &&

    New messages

    `. It's easy to assume that it renders nothing when `messageCount` is `0`, but it really renders the `0` itself! +উদাহরণস্বরূপ, একটি সাধারণ ভুল হলো কোড লেখা `messageCount &&

    New messages

    ` এর মতো। এটি সহজে মনে হতে পারে যে `messageCount` যদি `0` হয় তবে এটি কিছুই রেন্ডার করবে না, কিন্তু আসলে এটি `0` রেন্ডার করে! -To fix it, make the left side a boolean: `messageCount > 0 &&

    New messages

    `. +এটি ঠিক করতে, বাম পাশের মানটিকে বুলিয়ান করে তুলুন: `messageCount > 0 &&

    New messages

    `।
    -### Conditionally assigning JSX to a variable {/*conditionally-assigning-jsx-to-a-variable*/} +### শর্ত-সাপেক্ষে একটি ভেরিয়েবলে JSX অ্যাসাইন কর {/*conditionally-assigning-jsx-to-a-variable*/} -When the shortcuts get in the way of writing plain code, try using an `if` statement and a variable. You can reassign variables defined with [`let`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let), so start by providing the default content you want to display, the name: +যখন শর্টকাটগুলি সাধারণ কোড লেখার পথে বাধা দেয়, তখন একটি `if` স্টেটমেন্ট এবং একটি ভেরিয়েবল ব্যবহার করার চেষ্টা করুন। [`let`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let) দিয়ে সংজ্ঞায়িত ভেরিয়েবলগুলিকে পুনঃনির্ধারণ করা যায়, তাই শুরুতে আপনি প্রদর্শন করতে চান এমন ডিফল্ট কনটেন্টটি দিয়ে শুরু করুন, অর্থাৎ নাম: ```js let itemContent = name; ``` -Use an `if` statement to reassign a JSX expression to `itemContent` if `isPacked` is `true`: +`if` স্টেটমেন্ট ব্যবহার করে `itemContent`-কে একটি JSX এক্সপ্রেশন পুনঃনির্ধারণ করুন যদি `isPacked` সত্য হয়: ```js if (isPacked) { @@ -341,7 +341,7 @@ if (isPacked) { } ``` -[Curly braces open the "window into JavaScript".](/learn/javascript-in-jsx-with-curly-braces#using-curly-braces-a-window-into-the-javascript-world) Embed the variable with curly braces in the returned JSX tree, nesting the previously calculated expression inside of JSX: +[কার্লি ব্রেসের মাধ্যমে "জাভাস্ক্রিপ্টের জানালা খোলে।](/learn/javascript-in-jsx-with-curly-braces#using-curly-braces-a-window-into-the-javascript-world)" রিটার্নকৃত JSX ট্রিতে ভেরিয়েবলটি কার্লি ব্রেসের সাথে এম্বেড করুন এবং পূর্বে গণনা করা এক্সপ্রেশনটি JSX-এর ভেতরে নেস্ট করুন: ```js
  • @@ -349,7 +349,7 @@ if (isPacked) {
  • ``` -This style is the most verbose, but it's also the most flexible. Here it is in action: +এই স্টাইলটি সবচেয়ে ব্যাখ্যামূলক, তবে এটি সবচেয়ে নমনীয়ও। এখানে এটি কার্যকরভাবে প্রদর্শিত হচ্ছে: @@ -391,7 +391,7 @@ export default function PackingList() { -Like before, this works not only for text, but for arbitrary JSX too: +আগের মত, এটি শুধুমাত্র টেক্সটের জন্য নয়, বরং যেকোনও অর্বিট্রারি JSX-এর জন্যও কাজ করে: @@ -437,16 +437,16 @@ export default function PackingList() { -If you're not familiar with JavaScript, this variety of styles might seem overwhelming at first. However, learning them will help you read and write any JavaScript code -- and not just React components! Pick the one you prefer for a start, and then consult this reference again if you forget how the other ones work. +যদি আপনি জাভাস্ক্রিপ্টে নতুন হন, তাহলে বিভিন্ন স্টাইল প্রথমে কিছুটা জটিল মনে হতে পারে। তবে এগুলো শেখা আপনাকে যেকোনো জাভাস্ক্রিপ্ট কোড বুঝতে ও লিখতে সহায়তা করবে — এবং শুধু React কম্পোনেন্টেই নয়! যেটা আপনার সবচেয়ে সহজ মনে হয় তা দিয়ে শুরু করুন, এবং পরবর্তীতে অন্যগুলো মনে না থাকলে এই রেফারেন্সটি আবার দেখে নিতে পারেন। -* In React, you control branching logic with JavaScript. -* You can return a JSX expression conditionally with an `if` statement. -* You can conditionally save some JSX to a variable and then include it inside other JSX by using the curly braces. -* In JSX, `{cond ? : }` means *"if `cond`, render ``, otherwise ``"*. -* In JSX, `{cond && }` means *"if `cond`, render ``, otherwise nothing"*. -* The shortcuts are common, but you don't have to use them if you prefer plain `if`. +* React-এ, আপনি JavaScript দিয়ে শাখা লজিক নিয়ন্ত্রণ করেন। +* আপনি একটি `if` বিবৃতি দিয়ে শর্তসাপেক্ষে একটি JSX প্রকাশ্য ফিরিয়ে দিতে পারেন। +* আপনি কিছু JSX শর্তসাপেক্ষে একটি ভেরিয়েবলে সংরক্ষণ করতে পারেন এবং তারপর অন্য JSX-এর ভিতরে এটিকে অন্তর্ভুক্ত করতে পারেন কুরি ব্রেস ব্যবহার করে। +* JSX-এ, `{cond ? : }` এর অর্থ *"যদি `cond` হয়, তবে `` রেন্ডার করুন, অন্যথায় `` রেন্ডার করুন"*। +* JSX-এ, `{cond && }` এর অর্থ *"যদি `cond` হয়, তবে `` রেন্ডার করুন, অন্যথায় কিছুই নয়"*। +* শর্টকাটগুলো সাধারণ, তবে আপনি যদি সাধারণ `if` ব্যবহার করতে পছন্দ করেন তবে আপনাকে সেগুলো ব্যবহার করতে হবে না। @@ -454,9 +454,9 @@ If you're not familiar with JavaScript, this variety of styles might seem overwh -#### Show an icon for incomplete items with `? :` {/*show-an-icon-for-incomplete-items-with--*/} +#### "অপূর্ণ আইটেমগুলির জন্য `? :` সহ একটি আইকন দেখান" {/*show-an-icon-for-incomplete-items-with--*/} -Use the conditional operator (`cond ? a : b`) to render a ❌ if `isPacked` isn’t `true`. +"`isPacked` যদি `true` না হয় তবে একটি ❌ রেন্ডার করতে শর্তাধীন অপারেটর (`cond ? a : b`) ব্যবহার করুন।" @@ -534,15 +534,15 @@ export default function PackingList() { -#### Show the item importance with `&&` {/*show-the-item-importance-with-*/} +#### "আইটেমের গুরুত্ব `&&` ব্যবহার করে দেখান {/*show-the-item-importance-with-*/} -In this example, each `Item` receives a numerical `importance` prop. Use the `&&` operator to render "_(Importance: X)_" in italics, but only for items that have non-zero importance. Your item list should end up looking like this: +এই উদাহরণে, প্রতিটি `Item` একটি সংখ্যাগত `importance` প্রপ পায়। শূন্যের বাইরে গুরুত্ব থাকা আইটেমগুলির জন্য `_ (গুরুত্ব: X) _` ইতালিকসে রেন্ডার করতে `&&` অপারেটর ব্যবহার করুন। আপনার আইটেমের তালিকা এরকম দেখতে হবে: -* Space suit _(Importance: 9)_ -* Helmet with a golden leaf -* Photo of Tam _(Importance: 6)_ +* স্পেস স্যুট _(গুরুত্ব: ৯)_ +* স্বর্ণ পাতা যুক্ত হেলমেট +* ট্যামের ছবি _(গুরুত্ব: ৬)_ -Don't forget to add a space between the two labels! +দুই লেবেলের মধ্যে একটি স্পেস যুক্ত করতে ভুলবেন না!" @@ -582,7 +582,7 @@ export default function PackingList() { -This should do the trick: +এটি কাজটি সঠিকভাবে করবে:: @@ -624,15 +624,15 @@ export default function PackingList() { -Note that you must write `importance > 0 && ...` rather than `importance && ...` so that if the `importance` is `0`, `0` isn't rendered as the result! +"নোট করুন যে আপনাকে `importance > 0 && ...` লিখতে হবে `importance && ...` এর পরিবর্তে, যাতে `importance` যদি `0` হয়, তাহলে `0` ফলস্বরূপ রেন্ডার না হয়! -In this solution, two separate conditions are used to insert a space between the name and the importance label. Alternatively, you could use a Fragment with a leading space: `importance > 0 && <> ...` or add a space immediately inside the ``: `importance > 0 && ...`. +এই সমাধানে, নাম এবং গুরুত্ব লেবেলের মধ্যে একটি স্পেস যুক্ত করতে দুটি আলাদা শর্ত ব্যবহার করা হয়েছে। বিকল্পভাবে, আপনি একটি ফ্রাগমেন্ট ব্যবহার করতে পারেন একটি লিডিং স্পেস সহ: `importance > 0 && <> ...` অথবা `` এর ভিতরে অবিলম্বে একটি স্পেস যুক্ত করতে পারেন: `importance > 0 && ...`। -#### Refactor a series of `? :` to `if` and variables {/*refactor-a-series-of---to-if-and-variables*/} +#### একটি সিরিজ `? :` কে `if` এবং ভেরিয়েবল দ্বারা রিফ্যাক্টর করুন {/*refactor-a-series-of---to-if-and-variables*/} -This `Drink` component uses a series of `? :` conditions to show different information depending on whether the `name` prop is `"tea"` or `"coffee"`. The problem is that the information about each drink is spread across multiple conditions. Refactor this code to use a single `if` statement instead of three `? :` conditions. +এই `Drink` কম্পোনেন্টটি `name` প্রপ `"tea"` অথবা `"coffee"` এর উপর ভিত্তি করে ভিন্ন তথ্য প্রদর্শন করতে `? :` শর্তগুলির একটি সিরিজ ব্যবহার করে। সমস্যাটি হল প্রতিটি পানীয় সম্পর্কিত তথ্য বিভিন্ন শর্তের মধ্যে ছড়িয়ে ছিটিয়ে আছে। এই কোডটি তিনটি `? :` শর্তের পরিবর্তে একটি একক `if` বিবৃতি ব্যবহার করতে রিফ্যাক্টর করুন।" @@ -665,11 +665,11 @@ export default function DrinkList() { -Once you've refactored the code to use `if`, do you have further ideas on how to simplify it? +"আপনি যখন কোডটি `if` ব্যবহার করতে রিফ্যাক্টর করবেন, তখন কি আপনি এটি সরল করার জন্য আরও কিছু ধারণা আছে? -There are multiple ways you could go about this, but here is one starting point: +এটি করার জন্য বিভিন্ন উপায় রয়েছে, কিন্তু এখানে একটি শুরু পয়েন্ট রয়েছে:" @@ -712,9 +712,9 @@ export default function DrinkList() { -Here the information about each drink is grouped together instead of being spread across multiple conditions. This makes it easier to add more drinks in the future. +"এখানে প্রতিটি পানীয়ের তথ্য একসাথে গোষ্ঠীবদ্ধ করা হয়েছে, যা একাধিক শর্তের মধ্যে ছড়িয়ে ছিটিয়ে থাকার পরিবর্তে। এটি ভবিষ্যতে আরও পানীয় যুক্ত করা সহজ করে তোলে। -Another solution would be to remove the condition altogether by moving the information into objects: +অন্য একটি সমাধান হবে শর্তটি সম্পূর্ণরূপে অপসারণ করা, তথ্যগুলিকে অবজেক্টে স্থানান্তরিত করে:" diff --git a/src/content/learn/javascript-in-jsx-with-curly-braces.md b/src/content/learn/javascript-in-jsx-with-curly-braces.md index 736065b03..1bfbeed55 100644 --- a/src/content/learn/javascript-in-jsx-with-curly-braces.md +++ b/src/content/learn/javascript-in-jsx-with-curly-braces.md @@ -1,25 +1,25 @@ --- -title: JavaScript in JSX with Curly Braces +title: JSX এ কার্লি ব্রেসের মধ্যে জাভাস্ক্রিপ্ট --- -JSX lets you write HTML-like markup inside a JavaScript file, keeping rendering logic and content in the same place. Sometimes you will want to add a little JavaScript logic or reference a dynamic property inside that markup. In this situation, you can use curly braces in your JSX to open a window to JavaScript. +JSX আপনাকে জাভাস্ক্রিপ্ট ফাইলের মধ্যে HTML-এর মতো মার্কআপ লিখতে দেয়, যেখানে রেন্ডারিং লজিক এবং কন্টেন্ট একসাথে থাকে। মাঝে মাঝে আপনি এই মার্কআপের মধ্যে কিছু জাভাস্ক্রিপ্ট লজিক যোগ করতে বা ডায়নামিক প্রপার্টি রেফারেন্স করতে চাইবেন। এই পরিস্থিতিতে, আপনি আপনার JSX-এ `{ }` ব্যবহার করে জাভাস্ক্রিপ্টে প্রবেশ করতে পারবেন। -* How to pass strings with quotes -* How to reference a JavaScript variable inside JSX with curly braces -* How to call a JavaScript function inside JSX with curly braces -* How to use a JavaScript object inside JSX with curly braces +- কিভাবে কোটেশনসহ স্ট্রিং পাঠাতে হয় +- কিভাবে JSX-এ `{ }` দিয়ে জাভাস্ক্রিপ্ট ভেরিয়েবল রেফারেন্স করতে হয় +- কিভাবে `{ }` দিয়ে JSX-এ জাভাস্ক্রিপ্ট ফাংশন কল করতে হয় +- কিভাবে `{ }` দিয়ে JSX-এ জাভাস্ক্রিপ্ট অবজেক্ট ব্যবহার করতে হয় ## Passing strings with quotes {/*passing-strings-with-quotes*/} -When you want to pass a string attribute to JSX, you put it in single or double quotes: +যখন আপনি JSX-এ একটি স্ট্রিং অ্যাট্রিবিউট পাঠাতে চান, তখন এটি সিঙ্গেল বা ডাবল কোটেশনে রাখুন: @@ -41,9 +41,9 @@ export default function Avatar() { -Here, `"https://i.imgur.com/7vQD0fPs.jpg"` and `"Gregorio Y. Zara"` are being passed as strings. +এখানে, `"https://i.imgur.com/7vQD0fPs.jpg"` এবং `"Gregorio Y. Zara"` স্ট্রিং হিসেবে পাঠানো হয়েছে। -But what if you want to dynamically specify the `src` or `alt` text? You could **use a value from JavaScript by replacing `"` and `"` with `{` and `}`**: +কিন্তু যদি আপনি `src` বা `alt` টেক্সটকে ডাইনামিকভাবে নির্দিষ্ট করতে চান, তাহলে **`"` এবং `"` পরিবর্তে `{` এবং `}` ব্যবহার করে জাভাস্ক্রিপ্ট থেকে একটি মান ব্যবহার করতে পারেন**। @@ -67,11 +67,11 @@ export default function Avatar() { -Notice the difference between `className="avatar"`, which specifies an `"avatar"` CSS class name that makes the image round, and `src={avatar}` that reads the value of the JavaScript variable called `avatar`. That's because curly braces let you work with JavaScript right there in your markup! +একটি পার্থক্য লক্ষ্য করুন `className="avatar"`, যা `"avatar"` নামে একটি CSS ক্লাস নির্দিষ্ট করে যাতে ইমেজটি গোলাকৃতি হয়, এবং `src={avatar}` যা `avatar` নামে জাভাস্ক্রিপ্ট ভেরিয়েবলের মান পড়ে। এর কারণ হলো `{ }` আপনাকে আপনার মার্কআপে জাভাস্ক্রিপ্ট ব্যবহার করতে দেয়! -## Using curly braces: A window into the JavaScript world {/*using-curly-braces-a-window-into-the-javascript-world*/} +## `{ }` ব্যবহার: জাভাস্ক্রিপ্ট দুনিয়ার একটি জানালা {/*using-curly-braces-a-window-into-the-javascript-world*/} -JSX is a special way of writing JavaScript. That means it’s possible to use JavaScript inside it—with curly braces `{ }`. The example below first declares a name for the scientist, `name`, then embeds it with curly braces inside the `

    `: +JSX হল জাভাস্ক্রিপ্ট লেখার একটি বিশেষ পদ্ধতি। যার মানে, এর মধ্যে `{ }` ব্যবহার করে জাভাস্ক্রিপ্ট ব্যবহার করা সম্ভব। নিচের উদাহরণে প্রথমে একজন বিজ্ঞানীর নাম, `name`, ঘোষণা করা হয়েছে, তারপর `{ }` দিয়ে `

    ` ট্যাগের ভিতরে এটি এম্বেড করা হয়েছে: @@ -86,9 +86,9 @@ export default function TodoList() { -Try changing the `name`'s value from `'Gregorio Y. Zara'` to `'Hedy Lamarr'`. See how the list title changes? +`name` এর মান `'Gregorio Y. Zara'` থেকে `'Hedy Lamarr'` এ পরিবর্তন করার চেষ্টা করুন। দেখুন কিভাবে তালিকার শিরোনাম পরিবর্তিত হয়? -Any JavaScript expression will work between curly braces, including function calls like `formatDate()`: +কোনও জাভাস্ক্রিপ্ট এক্সপ্রেশন `{ }` এর মধ্যে কাজ করবে, যেমন ফাংশন কল `formatDate()`: @@ -111,18 +111,18 @@ export default function TodoList() { -### Where to use curly braces {/*where-to-use-curly-braces*/} +### `{ }` কোথায় ব্যবহার করবেন {/*where-to-use-curly-braces*/} -You can only use curly braces in two ways inside JSX: +আপনি JSX-এর মধ্যে দুটি উপায়ে `{ }` ব্যবহার করতে পারেন: -1. **As text** directly inside a JSX tag: `

    {name}'s To Do List

    ` works, but `<{tag}>Gregorio Y. Zara's To Do List` will not. -2. **As attributes** immediately following the `=` sign: `src={avatar}` will read the `avatar` variable, but `src="{avatar}"` will pass the string `"{avatar}"`. +১. **টেক্সট হিসেবে** সরাসরি একটি JSX ট্যাগের মধ্যে: `

    {name}'s To Do List

    ` কাজ করবে, কিন্তু `<{tag}>Gregorio Y. Zara's To Do List` কাজ করবে না। +২. **অ্যাট্রিবিউট হিসেবে** `=` চিহ্নের পরে সরাসরি: `src={avatar}` `avatar` ভেরিয়েবলটি পড়বে, কিন্তু `src="{avatar}"` `{avatar}` স্ট্রিংটি পাঠাবে। -## Using "double curlies": CSS and other objects in JSX {/*using-double-curlies-css-and-other-objects-in-jsx*/} +## "ডাবল কার্লি" ব্যবহার: CSS এবং অন্যান্য অবজেক্ট JSX-এ {/*using-double-curlies-css-and-other-objects-in-jsx*/} -In addition to strings, numbers, and other JavaScript expressions, you can even pass objects in JSX. Objects are also denoted with curly braces, like `{ name: "Hedy Lamarr", inventions: 5 }`. Therefore, to pass a JS object in JSX, you must wrap the object in another pair of curly braces: `person={{ name: "Hedy Lamarr", inventions: 5 }}`. +স্ট্রিং, সংখ্যা এবং অন্যান্য জাভাস্ক্রিপ্ট এক্সপ্রেশনের পাশাপাশি, আপনি JSX-এ অবজেক্টও পাঠাতে পারেন। অবজেক্টও `{ }` দিয়ে নির্ধারণ করা হয়, যেমন `{ name: "Hedy Lamarr", inventions: 5 }`। তাই JSX-এ একটি জাভাস্ক্রিপ্ট অবজেক্ট পাঠাতে আপনাকে অবজেক্টটিকে আরেকটি `{ }` এর মধ্যে মোড়াতে হবে: `person={{ name: "Hedy Lamarr", inventions: 5 }}`। -You may see this with inline CSS styles in JSX. React does not require you to use inline styles (CSS classes work great for most cases). But when you need an inline style, you pass an object to the `style` attribute: +আপনি এটি ইনলাইন CSS স্টাইলের সাথে দেখতে পারেন JSX-এ। React ইনলাইন স্টাইল ব্যবহার করতে বলে না (CSS ক্লাস বেশিরভাগ ক্ষেত্রে ভাল কাজ করে)। কিন্তু যখন আপনি একটি ইনলাইন স্টাইলের প্রয়োজন হয়, তখন আপনি `style` অ্যাট্রিবিউটে একটি অবজেক্ট পাঠাতে পারেন: @@ -148,9 +148,9 @@ ul { padding: 20px 20px 20px 40px; margin: 0; } -Try changing the values of `backgroundColor` and `color`. +`backgroundColor` এবং `color` এর মান পরিবর্তন করার চেষ্টা করুন। -You can really see the JavaScript object inside the curly braces when you write it like this: +আপনি আসলেই জাভাস্ক্রিপ্ট অবজেক্টটি `{ }` এর ভিতরে দেখতে পাবেন যখন এটি এভাবে লিখবেন: ```js {2-5}
      ``` -The next time you see `{{` and `}}` in JSX, know that it's nothing more than an object inside the JSX curlies! +পরের বার যখন আপনি `{{` এবং `}}` JSX-এ দেখবেন, জানবেন এটি কিছু নয় বরং JSX `{ }` এর ভিতরে একটি জাভাস্ক্রিপ্ট অবজেক্ট! -Inline `style` properties are written in camelCase. For example, HTML `
        ` would be written as `
          ` in your component. +ইনলাইন `style` প্রপার্টিগুলি camelCase-এ লেখা হয়। উদাহরণস্বরূপ, HTML `
            ` আপনার কম্পোনেন্টে `
              ` হিসাবে লেখা হবে। -## More fun with JavaScript objects and curly braces {/*more-fun-with-javascript-objects-and-curly-braces*/} +## জাভাস্ক্রিপ্ট অবজেক্ট এবং কার্লি ব্রেসের সাথে আরও মজার বিষয় {/*more-fun-with-javascript-objects-and-curly-braces*/} -You can move several expressions into one object, and reference them in your JSX inside curly braces: +আপনি একাধিক এক্সপ্রেশন এক অবজেক্টে স্থানান্তর করতে পারেন এবং JSX-এ `{ }` এর ভিতরে তাদের রেফারেন্স করতে পারেন: @@ -211,7 +211,7 @@ body > div > div { padding: 20px; } -In this example, the `person` JavaScript object contains a `name` string and a `theme` object: +এই উদাহরণে, `person` জাভাস্ক্রিপ্ট অবজেক্টটি একটি `name` স্ট্রিং এবং একটি `theme` অবজেক্ট ধারণ করে: ```js const person = { @@ -223,31 +223,31 @@ const person = { }; ``` -The component can use these values from `person` like so: +কম্পোনেন্টটি `person` থেকে এই মানগুলো ব্যবহার করতে পারে: ```js

              {person.name}'s Todos

              ``` -JSX is very minimal as a templating language because it lets you organize data and logic using JavaScript. +JSX খুবই সংক্ষিপ্ত একটি টেম্পলেটিং ভাষা কারণ এটি আপনাকে জাভাস্ক্রিপ্ট ব্যবহার করে ডেটা এবং লজিক সংগঠিত করতে দেয়। -Now you know almost everything about JSX: - -* JSX attributes inside quotes are passed as strings. -* Curly braces let you bring JavaScript logic and variables into your markup. -* They work inside the JSX tag content or immediately after `=` in attributes. -* `{{` and `}}` is not special syntax: it's a JavaScript object tucked inside JSX curly braces. +এখন আপনি JSX সম্পর্কে প্রায় সবকিছু জানেন: +- JSX অ্যাট্রিবিউট কোটেশনের মধ্যে থাকলে সেগুলো স্ট্রিং হিসেবে পাঠানো হয়। +- `{ }` জাভাস্ক্রিপ্ট লজিক এবং ভেরিয়েবলকে আপনার মার্কআপে নিয়ে আসে। +- এগুলি JSX ট্যাগের কন্টেন্টের ভিতরে বা অ্যাট্রিবিউট হিসেবে `=` এর পরে কাজ করে। +- `{{` এবং `}}` বিশেষ কোন সিনট্যাক্স নয়: এটি JSX `{ }` এর ভিতরে একটি জাভাস্ক্রিপ্ট অবজেক্ট। -#### Fix the mistake {/*fix-the-mistake*/} +#### ভুলটি ঠিক করুন {/*fix-the-mistake*/} + -This code crashes with an error saying `Objects are not valid as a React child`: +এই কোডটি ক্র্যাশ করে এবং `Objects are not valid as a React child` এরর প্রদর্শন করে। @@ -287,15 +287,17 @@ body > div > div { padding: 20px; } -Can you find the problem? +আপনি কি সমস্যাটি খুঁজে পেতে পারেন? -Look for what's inside the curly braces. Are we putting the right thing there? +কার্লি ব্রেসের ভেতরে কী রয়েছে, তা লক্ষ্য করুন। আমরা কি সঠিক জিনিসটি সেখানে রাখছি? -This is happening because this example renders *an object itself* into the markup rather than a string: `

              {person}'s Todos

              ` is trying to render the entire `person` object! Including raw objects as text content throws an error because React doesn't know how you want to display them. -To fix it, replace `

              {person}'s Todos

              ` with `

              {person.name}'s Todos

              `: + +এই সমস্যা হচ্ছে কারণ এই উদাহরণটি *একটি অবজেক্টকেই* মার্কআপে রেন্ডার করার চেষ্টা করছে একটি স্ট্রিংয়ের পরিবর্তে: `

              {person}'s Todos

              ` পুরো `person` অবজেক্টটি রেন্ডার করার চেষ্টা করছে! টেক্সট কন্টেন্ট হিসেবে সরাসরি অবজেক্ট অন্তর্ভুক্ত করলে এরর দেখা দেয়, কারণ React জানে না আপনি কীভাবে তা প্রদর্শন করতে চান। + +এটি ঠিক করতে, `

              {person}'s Todos

              ` পরিবর্তন করে `

              {person.name}'s Todos

              ` ব্যবহার করুন। @@ -337,9 +339,9 @@ body > div > div { padding: 20px; }
              -#### Extract information into an object {/*extract-information-into-an-object*/} +#### তথ্যগুলো একটি অবজেক্টে স্থানান্তর করুন {/*extract-information-into-an-object*/} -Extract the image URL into the `person` object. +ইমেজের URL `person` অবজেক্টে সংরক্ষণ করুন। @@ -381,7 +383,7 @@ body > div > div { padding: 20px; } -Move the image URL into a property called `person.imageUrl` and read it from the `` tag using the curlies: +ইমেজের URL-টি `person.imageUrl` নামে একটি প্রপার্টিতে স্থানান্তর করুন এবং কার্লি ব্রেস ব্যবহার করে এটি `` ট্যাগ থেকে পড়ুন: @@ -424,13 +426,13 @@ body > div > div { padding: 20px; } -#### Write an expression inside JSX curly braces {/*write-an-expression-inside-jsx-curly-braces*/} +#### JSX কার্লি ব্রেসের মধ্যে একটি এক্সপ্রেশন লিখুন {/*write-an-expression-inside-jsx-curly-braces*/} -In the object below, the full image URL is split into four parts: base URL, `imageId`, `imageSize`, and file extension. +নিচের অবজেক্টটিতে সম্পূর্ণ ইমেজ URL চারটি অংশে বিভক্ত: বেস URL, `imageId`, `imageSize`, এবং ফাইল এক্সটেনশন। -We want the image URL to combine these attributes together: base URL (always `'https://i.imgur.com/'`), `imageId` (`'7vQD0fP'`), `imageSize` (`'s'`), and file extension (always `'.jpg'`). However, something is wrong with how the `` tag specifies its `src`. +আমরা চাই যে ইমেজ URL এই অ্যাট্রিবিউটগুলোকে একত্রিত করে: বেস URL (সদা `'https://i.imgur.com/'`), `imageId` (`'7vQD0fP'`), `imageSize` (`'s'`), এবং ফাইল এক্সটেনশন (সদা `'.jpg'`)। তবে, `` ট্যাগটি এর `src` নির্দিষ্ট করার সময় কিছু ভুল হয়েছে। -Can you fix it? +আপনি কি এটি ঠিক করতে পারেন? @@ -474,15 +476,15 @@ body > div > div { padding: 20px; } -To check that your fix worked, try changing the value of `imageSize` to `'b'`. The image should resize after your edit. +আপনার ঠিক করা কাজ করেছে কিনা পরীক্ষা করতে, `imageSize` এর মান `'b'` এ পরিবর্তন করে দেখুন। আপনার সম্পাদনার পরে ইমেজের আকার পরিবর্তিত হওয়া উচিত। -You can write it as `src={baseUrl + person.imageId + person.imageSize + '.jpg'}`. +আপনি এটি এভাবে লিখতে পারেন: `src={baseUrl + person.imageId + person.imageSize + '.jpg'}`। -1. `{` opens the JavaScript expression -2. `baseUrl + person.imageId + person.imageSize + '.jpg'` produces the correct URL string -3. `}` closes the JavaScript expression +1. `{` জাভাস্ক্রিপ্ট এক্সপ্রেশন খুলছে +2. `baseUrl + person.imageId + person.imageSize + '.jpg'` সঠিক URL স্ট্রিং তৈরি করছে +3. `}` জাভাস্ক্রিপ্ট এক্সপ্রেশন বন্ধ করছে @@ -525,7 +527,7 @@ body > div > div { padding: 20px; } -You can also move this expression into a separate function like `getImageUrl` below: +আপনি এই এক্সপ্রেশনটিকে একটি আলাদা ফাংশনে, যেমন `getImageUrl`, এ স্থানান্তরিত করতে পারেন: @@ -580,7 +582,7 @@ body > div > div { padding: 20px; } -Variables and functions can help you keep the markup simple! +ভেরিয়েবল এবং ফাংশনগুলো আপনার মার্কআপকে সরল রাখতে সাহায্য করতে পারে! diff --git a/src/content/learn/passing-props-to-a-component.md b/src/content/learn/passing-props-to-a-component.md index aae682d14..f5b970cd2 100644 --- a/src/content/learn/passing-props-to-a-component.md +++ b/src/content/learn/passing-props-to-a-component.md @@ -1,26 +1,26 @@ --- -title: Passing Props to a Component +title: কম্পোনেন্টে প্রপস পাস করা --- -React components use *props* to communicate with each other. Every parent component can pass some information to its child components by giving them props. Props might remind you of HTML attributes, but you can pass any JavaScript value through them, including objects, arrays, and functions. +React কম্পোনেন্টগুলো *props* ব্যবহার করে একে অপরের সাথে যোগাযোগ করে। প্রতিটি parent কম্পোনেন্ট তার child কম্পোনেন্টগুলোকে props দিয়ে কিছু তথ্য পাঠাতে পারে। Props HTML attributes-এর মত মনে হতে পারে, তবে আপনি এর মাধ্যমে object, array এবং function সহ যেকোনো JavaScript মান পাঠাতে পারেন। -* How to pass props to a component -* How to read props from a component -* How to specify default values for props -* How to pass some JSX to a component -* How props change over time +* কীভাবে একটি কম্পোনেন্টে props পাঠাতে হয় +* কীভাবে একটি কম্পোনেন্ট থেকে props পড়তে হয় +* কীভাবে props-এর জন্য default মান নির্দিষ্ট করতে হয় +* কীভাবে একটি কম্পোনেন্টে কিছু JSX পাঠাতে হয় +* কীভাবে সময়ের সাথে সাথে props পরিবর্তিত হয় -## Familiar props {/*familiar-props*/} +## সুপরিচিত props {/*familiar-props*/} -Props are the information that you pass to a JSX tag. For example, `className`, `src`, `alt`, `width`, and `height` are some of the props you can pass to an ``: +প্রপস হলো সেই তথ্য যা আপনি একটি JSX ট্যাগে পাঠান। উদাহরণস্বরূপ, `className`, `src`, `alt`, `width`, এবং `height` হল কিছু প্রপস, যা আপনি একটি `` ট্যাগে পাঠাতে পারেন। @@ -51,11 +51,11 @@ body { min-height: 120px; } -The props you can pass to an `` tag are predefined (ReactDOM conforms to [the HTML standard](https://www.w3.org/TR/html52/semantics-embedded-content.html#the-img-element)). But you can pass any props to *your own* components, such as ``, to customize them. Here's how! +আপনি যে প্রপসগুলো `` ট্যাগে পাঠাতে পারেন, সেগুলো পূর্বনির্ধারিত (ReactDOM [HTML স্ট্যান্ডার্ড](https://www.w3.org/TR/html52/semantics-embedded-content.html#the-img-element)-এর সাথে সামঞ্জস্যপূর্ণ)। তবে আপনি *নিজের* কম্পোনেন্টগুলো, যেমন ``,-এ যেকোনো প্রপস পাঠাতে পারেন তাদের কাস্টমাইজ করার জন্য। এটি কীভাবে করবেন, দেখুন! -## Passing props to a component {/*passing-props-to-a-component*/} +## একটি কম্পোনেন্টে প্রপস পাঠানো {/*passing-props-to-a-component*/} -In this code, the `Profile` component isn't passing any props to its child component, `Avatar`: +এই কোডে, `Profile` কম্পোনেন্টটি এর চাইল্ড কম্পোনেন্ট `Avatar`-এ কোনো প্রপস পাঠাচ্ছে না: ```js export default function Profile() { @@ -65,11 +65,11 @@ export default function Profile() { } ``` -You can give `Avatar` some props in two steps. +আপনি দুটি ধাপে `Avatar`-এ কিছু props দিতে পারেন। -### Step 1: Pass props to the child component {/*step-1-pass-props-to-the-child-component*/} +### ধাপ ১: child কম্পোনেন্টে props পাঠানো {/*step-1-pass-props-to-the-child-component*/} -First, pass some props to `Avatar`. For example, let's pass two props: `person` (an object), and `size` (a number): +প্রথমে, কিছু প্রপস `Avatar`-এ পাঠান। উদাহরণস্বরূপ, দুটি প্রপস পাঠানো যাক: `person` (একটি অবজেক্ট), এবং `size` (একটি সংখ্যা): ```js export default function Profile() { @@ -84,15 +84,15 @@ export default function Profile() { -If double curly braces after `person=` confuse you, recall [they're merely an object](/learn/javascript-in-jsx-with-curly-braces#using-double-curlies-css-and-other-objects-in-jsx) inside the JSX curlies. +যদি `person=` এর পর ডাবল কার্লি ব্রেস আপনাকে বিভ্রান্ত করে, মনে রাখুন [এগুলো কেবল একটি অবজেক্ট](https://react.dev/learn/javascript-in-jsx-with-curly-braces#using-double-curlies-css-and-other-objects-in-jsx) JSX-এর কার্লি ব্রেসের ভিতরে। -Now you can read these props inside the `Avatar` component. +এখন আপনি এই props `Avatar` কম্পোনেন্টের ভিতরে পড়তে পারেন। -### Step 2: Read props inside the child component {/*step-2-read-props-inside-the-child-component*/} +### ধাপ ২: চাইল্ড কম্পোনেন্টের ভেতরে প্রপস পড়ুন {/*step-2-read-props-inside-the-child-component*/} -You can read these props by listing their names `person, size` separated by the commas inside `({` and `})` directly after `function Avatar`. This lets you use them inside the `Avatar` code, like you would with a variable. +আপনি `function Avatar`-এর ঠিক পরে `({` এবং `})` এর ভিতরে props-এর নামগুলো কমা দিয়ে আলাদা করে লিখে এই props পড়তে পারেন। এভাবে, আপনি সেগুলোকে ভেরিয়েবলের মত ব্যবহার করতে পারেন। ```js function Avatar({ person, size }) { @@ -100,9 +100,9 @@ function Avatar({ person, size }) { } ``` -Add some logic to `Avatar` that uses the `person` and `size` props for rendering, and you're done. +`person` এবং `size` props ব্যবহার করে `Avatar`-এ কিছু logic যোগ করুন, আর আপনার কাজ শেষ। -Now you can configure `Avatar` to render in many different ways with different props. Try tweaking the values! +এখন আপনি বিভিন্ন props-এর সাথে `Avatar`-কে বিভিন্ন উপায়ে রেন্ডার করতে পারেন। মান পরিবর্তন করে দেখুন! @@ -168,9 +168,9 @@ body { min-height: 120px; } -Props let you think about parent and child components independently. For example, you can change the `person` or the `size` props inside `Profile` without having to think about how `Avatar` uses them. Similarly, you can change how the `Avatar` uses these props, without looking at the `Profile`. +প্রপস আপনাকে প্যারেন্ট এবং চাইল্ড কম্পোনেন্টগুলোকে স্বাধীনভাবে ভাবতে সাহায্য করে। উদাহরণস্বরূপ, আপনি Profile-এর মধ্যে person বা size প্রপস পরিবর্তন করতে পারেন, Avatar কীভাবে সেগুলো ব্যবহার করে তা নিয়ে চিন্তা না করেই। একইভাবে, আপনি Avatar-এ প্রপসগুলো কীভাবে ব্যবহৃত হচ্ছে তা পরিবর্তন করতে পারেন, Profile-এর দিকে না তাকিয়েই। -You can think of props like "knobs" that you can adjust. They serve the same role as arguments serve for functions—in fact, props _are_ the only argument to your component! React component functions accept a single argument, a `props` object: +আপনি প্রপসকে “নব” বা নিয়ন্ত্রণ কাঁটা হিসেবে ভাবতে পারেন যা আপনি সামঞ্জস্য করতে পারেন। এগুলো আসলে ফাংশনের আর্গুমেন্টের মতো কাজ করে—আসলে, প্রপস হচ্ছে আপনার কম্পোনেন্টের একমাত্র আর্গুমেন্ট! React কম্পোনেন্ট ফাংশনগুলো একটি মাত্র আর্গুমেন্ট, অর্থাৎ একটি প্রপস অবজেক্ট গ্রহণ করে। ```js function Avatar(props) { @@ -180,11 +180,11 @@ function Avatar(props) { } ``` -Usually you don't need the whole `props` object itself, so you destructure it into individual props. +সাধারণত আপনাকে সম্পূর্ণ `props` object প্রয়োজন হয় না, তাই আপনি এটি আলাদা props এ ভেঙে ফেলেন। -**Don't miss the pair of `{` and `}` curlies** inside of `(` and `)` when declaring props: +**প্রপস ডিক্লেয়ার করার সময় `{` এবং `}` জোড়া মিস করবেন না** `(` এবং `)` এর ভেতরে: ```js function Avatar({ person, size }) { @@ -192,7 +192,7 @@ function Avatar({ person, size }) { } ``` -This syntax is called ["destructuring"](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Unpacking_fields_from_objects_passed_as_a_function_parameter) and is equivalent to reading properties from a function parameter: +এই সিনট্যাক্সটিকে ["ডিস্ট্রাকচারিং"](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Unpacking_fields_from_objects_passed_as_a_function_parameter) বলা হয় এবং এটি ফাংশন প্যারামিটার থেকে প্রপার্টি পড়ার সমতুল্য। ```js function Avatar(props) { @@ -204,9 +204,9 @@ function Avatar(props) { -## Specifying a default value for a prop {/*specifying-a-default-value-for-a-prop*/} +## প্রপের জন্য একটি ডিফল্ট মান নির্ধারণ করা {/*specifying-a-default-value-for-a-prop*/} -If you want to give a prop a default value to fall back on when no value is specified, you can do it with the destructuring by putting `=` and the default value right after the parameter: +যদি আপনি কোনো প্রপের জন্য ডিফল্ট মান নির্ধারণ করতে চান, যাতে কোনো মান নির্দিষ্ট না থাকলে তা প্রযোজ্য হয়, তাহলে ডিস্ট্রাকচারিংয়ে প্যারামিটারের পরে `=` এবং ডিফল্ট মানটি যোগ করতে পারেন: ```js function Avatar({ person, size = 100 }) { @@ -214,13 +214,13 @@ function Avatar({ person, size = 100 }) { } ``` -Now, if `` is rendered with no `size` prop, the `size` will be set to `100`. +এখন, যদি `` কোনো `size` প্রপ ছাড়া রেন্ডার করা হয়, তাহলে `size` সেট হবে `100`। -The default value is only used if the `size` prop is missing or if you pass `size={undefined}`. But if you pass `size={null}` or `size={0}`, the default value will **not** be used. +ডিফল্ট মানটি কেবল তখনই ব্যবহৃত হবে যদি `size` প্রপটি অনুপস্থিত থাকে অথবা আপনি `size={undefined}` পাঠান। তবে, যদি আপনি `size={null}` বা `size={0}` পাঠান, তাহলে ডিফল্ট মান **ব্যবহৃত হবে না**। -## Forwarding props with the JSX spread syntax {/*forwarding-props-with-the-jsx-spread-syntax*/} +## JSX স্প্রেড syntax এর সাথে props ফরোয়ার্ড করা {/*forwarding-props-with-the-jsx-spread-syntax*/} -Sometimes, passing props gets very repetitive: +কখনও কখনও, props পাঠানো খুবই পুনরাবৃত্তিমূলক হতে পারে: ```js function Profile({ person, size, isSepia, thickBorder }) { @@ -237,7 +237,7 @@ function Profile({ person, size, isSepia, thickBorder }) { } ``` -There's nothing wrong with repetitive code—it can be more legible. But at times you may value conciseness. Some components forward all of their props to their children, like how this `Profile` does with `Avatar`. Because they don't use any of their props directly, it can make sense to use a more concise "spread" syntax: +পুনরাবৃত্তিমূলক কোডে কোনো সমস্যা নেই—এটি আরও বোধগম্য হতে পারে। কিন্তু কখনও কখনও আপনি সংক্ষিপ্ততা মূল্যায়ন করতে পারেন। কিছু কম্পোনেন্ট তাদের সমস্ত props child কম্পোনেন্টে ফরোয়ার্ড করে, যেমন `Profile` `Avatar`-এর সাথে করে। যেহেতু তারা কোনো props সরাসরি ব্যবহার করে না, তাই একটি সংক্ষিপ্ত "স্প্রেড" syntax ব্যবহার করা যেতে পারে: ```js function Profile(props) { @@ -249,13 +249,13 @@ function Profile(props) { } ``` -This forwards all of `Profile`'s props to the `Avatar` without listing each of their names. +এটি `Profile` এর সমস্ত props `Avatar` এ ফরোয়ার্ড করে কোনো নাম তালিকা ছাড়াই। -**Use spread syntax with restraint.** If you're using it in every other component, something is wrong. Often, it indicates that you should split your components and pass children as JSX. More on that next! +**স্প্রেড syntax নিয়ন্ত্রণের সাথে ব্যবহার করুন।** যদি আপনি এটি প্রতিটি কম্পোনেন্টে ব্যবহার করেন, তাহলে কিছু সমস্যা রয়েছে। সাধারণত, এটি নির্দেশ করে যে আপনাকে আপনার কম্পোনেন্টগুলো ভাগ করা উচিত এবং children JSX হিসেবে পাঠানো উচিত। -## Passing JSX as children {/*passing-jsx-as-children*/} +## children হিসেবে JSX পাঠানো {/*passing-jsx-as-children*/} -It is common to nest built-in browser tags: +বিল্ট-ইন ব্রাউজার ট্যাগ নেস্ট করা সাধারণ: ```js
              @@ -263,7 +263,7 @@ It is common to nest built-in browser tags:
              ``` -Sometimes you'll want to nest your own components the same way: +আপনার নিজস্ব কম্পোনেন্টগুলো একইভাবে নেস্ট করতে পারেন: ```js @@ -271,7 +271,7 @@ Sometimes you'll want to nest your own components the same way: ``` -When you nest content inside a JSX tag, the parent component will receive that content in a prop called `children`. For example, the `Card` component below will receive a `children` prop set to `` and render it in a wrapper div: +যখন আপনি একটি JSX ট্যাগের ভিতরে কন্টেন্ট নেস্ট করেন, parent কম্পোনেন্ট সেই কন্টেন্টকে একটি `children` prop-এ গ্রহণ করবে। উদাহরণস্বরূপ, নিচের `Card` কম্পোনেন্ট একটি `children` prop গ্রহণ করবে যেটি `` সেট করা আছে এবং এটি একটি wrapper div এ রেন্ডার করবে: @@ -347,17 +347,17 @@ export function getImageUrl(person, size = 's') { -Try replacing the `` inside `` with some text to see how the `Card` component can wrap any nested content. It doesn't need to "know" what's being rendered inside of it. You will see this flexible pattern in many places. +`Card`-এর ভিতরে `` পরিবর্তন করে কিছু টেক্সট যোগানোর চেষ্টা করুন এবং দেখুন কীভাবে `Card` যেকোনো নেস্টেড কন্টেন্টকে র‍্যাপ করতে পারে। এটি জানে না যে এর ভিতরে কী রেন্ডার করা হচ্ছে। আপনি এই নমনীয় pattern অনেক জায়গায় দেখতে পাবেন। -You can think of a component with a `children` prop as having a "hole" that can be "filled in" by its parent components with arbitrary JSX. You will often use the `children` prop for visual wrappers: panels, grids, etc. +একটি `children` prop সহ কম্পোনেন্টকে এমন একটি "ছিদ্র" হিসেবে ভাবতে পারেন যা parent কম্পোনেন্টগুলো যেকোনো JSX দিয়ে "পূর্ণ" করতে পারে। আপনি ভিজ্যুয়াল wrapper-দের জন্য children prop প্রায়ই ব্যবহার করবেন: প্যানেল, গ্রিড ইত্যাদি। ## How props change over time {/*how-props-change-over-time*/} -The `Clock` component below receives two props from its parent component: `color` and `time`. (The parent component's code is omitted because it uses [state](/learn/state-a-components-memory), which we won't dive into just yet.) +নিচের `Clock` কম্পোনেন্টটি parent কম্পোনেন্ট থেকে দুটি props গ্রহণ করে: `color` এবং `time`। (parent কম্পোনেন্টের কোডটি বাদ দেওয়া হয়েছে কারণ এটি [state](/learn/state-a-components-memory) ব্যবহার করে, যা আমরা এখনো আলোচনা করছি না।) -Try changing the color in the select box below: +নীচের সিলেক্ট বক্সে রং পরিবর্তন করার চেষ্টা করুন: @@ -407,21 +407,21 @@ export default function App() { -This example illustrates that **a component may receive different props over time.** Props are not always static! Here, the `time` prop changes every second, and the `color` prop changes when you select another color. Props reflect a component's data at any point in time, rather than only in the beginning. +এই উদাহরণটি দেখায় যে **একটি কম্পোনেন্ট সময়ের সাথে সাথে বিভিন্ন প্রপস পেতে পারে।** প্রপস সর্বদা স্থির নয়! এখানে, `time` প্রপ প্রতি সেকেন্ডে পরিবর্তিত হয়, এবং `color` প্রপটি যখন আপনি অন্য রঙ নির্বাচন করেন তখন পরিবর্তিত হয়। প্রপস যেকোনো সময়ে একটি কম্পোনেন্টের ডেটা প্রতিফলিত করে, শুধুমাত্র শুরুতে নয়। -However, props are [immutable](https://en.wikipedia.org/wiki/Immutable_object)—a term from computer science meaning "unchangeable". When a component needs to change its props (for example, in response to a user interaction or new data), it will have to "ask" its parent component to pass it _different props_—a new object! Its old props will then be cast aside, and eventually the JavaScript engine will reclaim the memory taken by them. +তবে, প্রপস [অপরিবর্তনীয়](https://en.wikipedia.org/wiki/Immutable_object)—এটি একটি কম্পিউটার বিজ্ঞান সম্পর্কিত শব্দ যার অর্থ "অপরিবর্তনীয়"। যখন একটি কম্পোনেন্ট তার প্রপস পরিবর্তন করতে চায় (যেমন, ব্যবহারকারীর একটি ক্রিয়ার প্রতিক্রিয়া হিসেবে বা নতুন ডেটার জন্য), তখন এটি তার প্যারেন্ট কম্পোনেন্টকে _বিভিন্ন প্রপস_—একটি নতুন অবজেক্ট পাঠানোর জন্য "বিনীত" করবে! তারপর তার পুরানো প্রপস বাদ দেওয়া হবে, এবং অবশেষে জাভাস্ক্রিপ্ট ইঞ্জিন তাদের দ্বারা নেওয়া মেমরি পুনরুদ্ধার করবে। -**Don't try to "change props".** When you need to respond to the user input (like changing the selected color), you will need to "set state", which you can learn about in [State: A Component's Memory.](/learn/state-a-components-memory) +**"প্রপস পরিবর্তন করার চেষ্টা করবেন না"।** যখন আপনাকে ব্যবহারকারীর ইনপুটের প্রতিক্রিয়া জানাতে হবে (যেমন নির্বাচিত রঙ পরিবর্তন করা), তখন আপনাকে "স্টেট সেট" করতে হবে, যা আপনি [স্টেট: একটি কম্পোনেন্টের মেমরি](/learn/state-a-components-memory) থেকে শিখতে পারেন। -* To pass props, add them to the JSX, just like you would with HTML attributes. -* To read props, use the `function Avatar({ person, size })` destructuring syntax. -* You can specify a default value like `size = 100`, which is used for missing and `undefined` props. -* You can forward all props with `` JSX spread syntax, but don't overuse it! -* Nested JSX like `` will appear as `Card` component's `children` prop. -* Props are read-only snapshots in time: every render receives a new version of props. -* You can't change props. When you need interactivity, you'll need to set state. +* প্রপস পাঠাতে, সেগুলো JSX-এ যুক্ত করুন, যেমন আপনি HTML অ্যাট্রিবিউটগুলোর সাথে করেন। +* প্রপস পড়তে, `function Avatar({ person, size })` ডিস্ট্রাকচারিং সিনট্যাক্স ব্যবহার করুন। +* আপনি একটি ডিফল্ট মান নির্ধারণ করতে পারেন যেমন `size = 100`, যা অনুপস্থিত এবং `undefined` প্রপসের জন্য ব্যবহৃত হয়। +* আপনি সমস্ত প্রপসকে `` JSX স্প্রেড সিনট্যাক্সের মাধ্যমে ফরওয়ার্ড করতে পারেন, তবে এটিকে অতিরিক্ত ব্যবহার করবেন না! +* নেস্টেড JSX যেমন `` `Card` কম্পোনেন্টের `children` প্রপ হিসেবে উপস্থিত হবে। +* প্রপস হল সময়ের একটি রিড-অনলি স্ন্যাপশট: প্রতিটি রেন্ডারে প্রপসের একটি নতুন সংস্করণ পাওয়া যায়। +* আপনি প্রপস পরিবর্তন করতে পারবেন না। যখন আপনাকে ইন্টারঅ্যাকটিভিটি প্রয়োজন, তখন আপনাকে স্টেট সেট করতে হবে। @@ -429,9 +429,9 @@ However, props are [immutable](https://en.wikipedia.org/wiki/Immutable_object) -#### Extract a component {/*extract-a-component*/} +#### একটি কম্পোনেন্ট বের করুন {/*extract-a-component*/} -This `Gallery` component contains some very similar markup for two profiles. Extract a `Profile` component out of it to reduce the duplication. You'll need to choose what props to pass to it. +এই `Gallery` কম্পোনেন্টে দুটি প্রফাইলের জন্য কিছু খুব অনুরূপ মার্কআপ রয়েছে। ডুপ্লিকেশন কমানোর জন্য একটি `Profile` কম্পোনেন্ট বের করুন। আপনাকে এটি কী প্রপস পাঠাতে হবে তা নির্বাচন করতে হবে। @@ -524,15 +524,15 @@ li { margin: 5px; } -Start by extracting the markup for one of the scientists. Then find the pieces that don't match it in the second example, and make them configurable by props. +একজন বিজ্ঞানীর জন্য মার্কআপ বের করার মাধ্যমে শুরু করুন। তারপর দ্বিতীয় উদাহরণে যা মেলে না তা খুঁজে বের করুন এবং সেগুলোকে প্রপস দ্বারা কনফিগারেবল করুন। -In this solution, the `Profile` component accepts multiple props: `imageId` (a string), `name` (a string), `profession` (a string), `awards` (an array of strings), `discovery` (a string), and `imageSize` (a number). +এই সমাধানে, `Profile` কম্পোনেন্টটি একাধিক প্রপ গ্রহণ করে: `imageId` (একটি স্ট্রিং), `name` (একটি স্ট্রিং), `profession` (একটি স্ট্রিং), `awards` (স্ট্রিংয়ের একটি অ্যারে), `discovery` (একটি স্ট্রিং), এবং `imageSize` (একটি সংখ্যা)। -Note that the `imageSize` prop has a default value, which is why we don't pass it to the component. +মনে রাখবেন যে `imageSize` প্রপের একটি ডিফল্ট মান রয়েছে, এই কারণে আমরা এটি কম্পোনেন্টে পাঠাচ্ছি না। @@ -630,9 +630,9 @@ li { margin: 5px; } -Note how you don't need a separate `awardCount` prop if `awards` is an array. Then you can use `awards.length` to count the number of awards. Remember that props can take any values, and that includes arrays too! +মনে রাখবেন যে যদি `awards` একটি অ্যারে হয় তবে আপনাকে আলাদা `awardCount` প্রপের প্রয়োজন নেই। আপনি `awards.length` ব্যবহার করে পুরস্কারের সংখ্যা গুণতে পারেন। মনে রাখবেন যে প্রপস যেকোনো মান নিতে পারে, এবং এর মধ্যে অ্যারেও রয়েছে! -Another solution, which is more similar to the earlier examples on this page, is to group all information about a person in a single object, and pass that object as one prop: +আরেকটি সমাধান, যা এই পৃষ্ঠায় আগের উদাহরণগুলির সাথে আরও সাদৃশ্যপূর্ণ, হল একটি ব্যক্তির সম্পর্কে সমস্ত তথ্য একটি একক অবজেক্টে গ্রুপ করা এবং সেই অবজেক্টটি একটি প্রপ হিসেবে পাঠানো: @@ -727,15 +727,15 @@ li { margin: 5px; } -Although the syntax looks slightly different because you're describing properties of a JavaScript object rather than a collection of JSX attributes, these examples are mostly equivalent, and you can pick either approach. +যদিও সিনট্যাক্সটি কিছুটা ভিন্ন দেখাচ্ছে কারণ আপনি একটি জাভাস্ক্রিপ্ট অবজেক্টের প্রপার্টি বর্ণনা করছেন, এটি JSX অ্যাট্রিবিউটগুলোর একটি সংগ্রহের পরিবর্তে, এই উদাহরণগুলি প্রধানত সমতুল্য, এবং আপনি যেকোনো একটি পদ্ধতি বেছে নিতে পারেন। -#### Adjust the image size based on a prop {/*adjust-the-image-size-based-on-a-prop*/} +#### একটি প্রপের উপর ভিত্তি করে ইমেজের আকার সমন্বয় করুন {/*adjust-the-image-size-based-on-a-prop*/} -In this example, `Avatar` receives a numeric `size` prop which determines the `` width and height. The `size` prop is set to `40` in this example. However, if you open the image in a new tab, you'll notice that the image itself is larger (`160` pixels). The real image size is determined by which thumbnail size you're requesting. +আপনার উদাহরণে, `Avatar` একটি সংখ্যাগত `size` প্রপ গ্রহণ করে যা `` এর প্রস্থ এবং উচ্চতা নির্ধারণ করে। এই উদাহরণে, `size` প্রপটি `40` এ সেট করা হয়েছে। তবে, যদি আপনি নতুন ট্যাবে চিত্রটি খোলেন, আপনি লক্ষ্য করবেন যে চিত্রের আকার আসলে বড় (`160` পিক্সেল)। বাস্তব চিত্রের আকার নির্ধারণ করা হয় আপনি কোন থাম্বনেল আকারটি অনুরোধ করছেন তার দ্বারা। -Change the `Avatar` component to request the closest image size based on the `size` prop. Specifically, if the `size` is less than `90`, pass `'s'` ("small") rather than `'b'` ("big") to the `getImageUrl` function. Verify that your changes work by rendering avatars with different values of the `size` prop and opening images in a new tab. +`Avatar` উপাদানটি পরিবর্তন করুন যাতে `size` প্রপের উপর ভিত্তি করে সবচেয়ে কাছের চিত্রের আকার অনুরোধ করা হয়। বিশেষভাবে, যদি `size` `90` এর কম হয়, তাহলে `getImageUrl` ফাংশনে `'s'` ("ছোট") পাস করুন `'b'` ("বড়") এর পরিবর্তে। আপনার পরিবর্তনগুলি কার্যকর কিনা তা যাচাই করুন বিভিন্ন `size` প্রপ মান দিয়ে অ্যাভাটারগুলি রেন্ডার করে এবং নতুন ট্যাবে চিত্রগুলি খুলে। @@ -848,7 +848,7 @@ export function getImageUrl(person, size) { -You could also show a sharper image for high DPI screens by taking [`window.devicePixelRatio`](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio) into account: +আপনি উচ্চ DPI স্ক্রীনের জন্য আরও তীক্ষ্ণ চিত্রও দেখাতে পারেন `window.devicePixelRatio` কে বিবেচনায় নিয়ে: [MDN ডোকুমেন্টেশন](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio) @@ -919,13 +919,13 @@ export function getImageUrl(person, size) { -Props let you encapsulate logic like this inside the `Avatar` component (and change it later if needed) so that everyone can use the `` component without thinking about how the images are requested and resized. +প্রপগুলি আপনাকে `Avatar` উপাদানের ভিতরে এইরকম লজিক এনক্যাপসুলেট করতে দেয় (এবং প্রয়োজনে পরে এটি পরিবর্তন করতে) যাতে সবাই `` উপাদানটি ব্যবহার করতে পারে চিন্তা না করেই যে চিত্রগুলি কিভাবে অনুরোধ করা হয় এবং আকার পরিবর্তন করা হয়। -#### Passing JSX in a `children` prop {/*passing-jsx-in-a-children-prop*/} +#### `children` প্রপে JSX পাস করা {/*passing-jsx-in-a-children-prop*/} -Extract a `Card` component from the markup below, and use the `children` prop to pass different JSX to it: +নিচের মার্কআপ থেকে একটি `Card` উপাদান বের করুন এবং `children` প্রপ ব্যবহার করে এতে ভিন্ন ভিন্ন JSX পাঠান: @@ -983,13 +983,13 @@ h1 { -Any JSX you put inside of a component's tag will be passed as the `children` prop to that component. +আপনি একটি উপাদানের ট্যাগের ভিতরে যে কোনও JSX রাখলে সেটি সেই উপাদানের `children` প্রপ হিসেবে পাঠানো হবে। -This is how you can use the `Card` component in both places: +এভাবে আপনি উভয় স্থানে `Card` উপাদানটি ব্যবহার করতে পারেন: @@ -1051,7 +1051,7 @@ h1 { -You can also make `title` a separate prop if you want every `Card` to always have a title: +আপনি যদি চান যে প্রতিটি `Card`-এ সব সময় একটি শিরোনাম থাকুক, তাহলে `title`-কে একটি পৃথক প্রপ হিসাবেও তৈরি করতে পারেন: diff --git a/src/content/learn/tutorial-tic-tac-toe.md b/src/content/learn/tutorial-tic-tac-toe.md index d37791456..ac463124c 100644 --- a/src/content/learn/tutorial-tic-tac-toe.md +++ b/src/content/learn/tutorial-tic-tac-toe.md @@ -1,31 +1,30 @@ --- -title: 'Tutorial: Tic-Tac-Toe' +title: 'টিউটোরিয়াল: Tic-Tac-Toe' --- -You will build a small tic-tac-toe game during this tutorial. This tutorial does not assume any existing React knowledge. The techniques you'll learn in the tutorial are fundamental to building any React app, and fully understanding it will give you a deep understanding of React. +আপনি এই টিউটোরিয়ালে একটি ছোট টিক-ট্যাক-টো গেম তৈরি করবেন। এই টিউটোরিয়ালটিতে কোনও পূর্ববর্তী রিয়েক্ট জ্ঞানের প্রয়োজনীয়তা নেই। আপনি যে প্রযুক্তিগুলি এই টিউটোরিয়ালে শিখবেন তা যেকোন রিয়েক্ট অ্যাপ তৈরি করার জন্য মৌলিক জ্ঞান, এবং এটি সম্পূর্ণভাবে বুঝতে পারলে এটি আপনাকে রিয়েক্ট সম্পর্কে একটি গভীর ধারণা দেবে। -This tutorial is designed for people who prefer to **learn by doing** and want to quickly try making something tangible. If you prefer learning each concept step by step, start with [Describing the UI.](/learn/describing-the-ui) +এই টিউটোরিয়ালটি তাদের জন্য ডিজাইন করা হয়েছে যারা কাজ করে শিখতে পছন্দ করেন এবং দ্রুত কিছু বাস্তবধর্মী কিছু তৈরি করার চেষ্টা করতে চান। যদি আপনি ধাপে ধাপে প্রতিটি ধারণা শেখাকে অগ্রাধিকার দিতে চান, তবে [Describing the UI](/learn/describing-the-ui) দিয়ে শুরু করুন। -The tutorial is divided into several sections: +এই টিউটোরিয়ালটি কয়েকটি বিভাগে বিভক্ত: -- [Setup for the tutorial](#setup-for-the-tutorial) will give you **a starting point** to follow the tutorial. -- [Overview](#overview) will teach you **the fundamentals** of React: components, props, and state. -- [Completing the game](#completing-the-game) will teach you **the most common techniques** in React development. -- [Adding time travel](#adding-time-travel) will give you **a deeper insight** into the unique strengths of React. +- [Setup for the tutorial](#setup-for-the-tutorial) আপনাকে একেবারে গোড়া থেকে শুরু করাবে, যাতে আপনি টিউটোরিয়ালটি অনুসরণ করতে পারেন। +- [Overview](#overview) **রিয়েক্টের মৌলিক ধারণাগুলি** শেখাবে:যেমন ধরুন- কম্পোনেন্ট, প্রপস এবং স্টেট। +- [Completing the game](#completing-the-game) আপনাকে **রিয়েক্ট ডেভেলপমেন্টে সবচেয়ে প্রচলিত কৌশলগুলি** শেখাবে। +- [Adding time travel](#adding-time-travel) আপনাকে রিয়েক্টের অনন্য শক্তিগুলি সম্পর্কে **একটি গভীর পরিজ্ঞান** দেবে। -### What are you building? {/*what-are-you-building*/} +### আপনি কি তৈরি করছেন? {/*what-are-you-building*/} -In this tutorial, you'll build an interactive tic-tac-toe game with React. - -You can see what it will look like when you're finished here: +এই টিউটোরিয়ালে, আপনি রিয়েক্টের সাথে একটি ইন্টারঅ্যাকটিভ টিক-ট্যাক-টো গেম তৈরি করবেন। +আপনি এখানে দেখতে পারেন এটি আপনার শেষ হওয়ার পর কেমন দেখতে হবে: @@ -194,15 +193,15 @@ body { -If the code doesn't make sense to you yet, or if you are unfamiliar with the code's syntax, don't worry! The goal of this tutorial is to help you understand React and its syntax. +যদি কোডটি এখনও আপনার কাছে বোঝা না যায়, বা কোডের সিনট্যাক্সের সাথে আপনি পরিচিত না হন, তবে চিন্তা করবেন না! এই টিউটোরিয়ালের লক্ষ্য হল আপনাকে রিয়েক্ট এবং এর সিনট্যাক্স বুঝতে সাহায্য করা। -We recommend that you check out the tic-tac-toe game above before continuing with the tutorial. One of the features that you'll notice is that there is a numbered list to the right of the game's board. This list gives you a history of all of the moves that have occurred in the game, and it is updated as the game progresses. +আমরা আপনাকে টিউটোরিয়ালটি চালিয়ে যাওয়ার আগে উপরের টিক-ট্যাক-টো গেমটি দেখার পরামর্শ দিচ্ছি। আপনি যে বৈশিষ্ট্যটি লক্ষ্য করবেন তা হল গেমের বোর্ডের ডান দিকে একটি নম্বরযুক্ত তালিকা রয়েছে। এই তালিকাটি গেমে ঘটে যাওয়া সমস্ত ধাপগুলির ইতিবৃত্ত দেখায় এবং এটি গেমের অগ্রগতির সাথে আপডেট হয়। -Once you've played around with the finished tic-tac-toe game, keep scrolling. You'll start with a simpler template in this tutorial. Our next step is to set you up so that you can start building the game. +একবার আপনি সম্পন্ন টিক-ট্যাক-টো গেমটি নিয়ে খেলা শুরু করলে, স্ক্রোল করতে থাকুন। এই টিউটোরিয়ালে আপনি একটি সহজ টেমপ্লেট দিয়ে শুরু করবেন। আমাদের পরবর্তী পদক্ষেপ হল আপনি যাতে গেমটি তৈরি করা শুরু করতে পারেন সেভাবে আপনাকে তৈরি করা। -## Setup for the tutorial {/*setup-for-the-tutorial*/} +## টিউটোরিয়ালের জন্য সেটআপ {/*setup-for-the-tutorial*/} -In the live code editor below, click **Fork** in the top-right corner to open the editor in a new tab using the website CodeSandbox. CodeSandbox lets you write code in your browser and preview how your users will see the app you've created. The new tab should display an empty square and the starter code for this tutorial. +নিচের লাইভ কোড এডিটরটিতে, **Fork** বাটনে ক্লিক করুন, যা উপরের ডান কোণায় রয়েছে, CodeSandbox ওয়েবসাইট ব্যবহার করে নতুন ট্যাবে এডিটরটিতে খুলতে। CodeSandbox আপনাকে আপনার ব্রাউজারে কোড লেখার সুযোগ দেয় এবং আপনি যে অ্যাপটি তৈরি করেছেন তা আপনার ব্যবহারকারীরা কিভাবে দেখতে পাবে তা প্রিভিউ করতে দেয়। নতুন ওপেন হওয়া ট্যাবটি একটি খালি বর্গ এবং এই টিউটোরিয়ালের জন্য শুরু কোড প্রদর্শন করবে। @@ -261,33 +260,33 @@ body { -You can also follow this tutorial using your local development environment. To do this, you need to: +আপনি আপনার পিসিতে লোকাল ডেভেলপমেন্ট করেও এই টিউটোরিয়ালটি অনুসরণ করতে পারেন। এটি করতে, আপনাকে: -1. Install [Node.js](https://nodejs.org/en/) -1. In the CodeSandbox tab you opened earlier, press the top-left corner button to open the menu, and then choose **Download Sandbox** in that menu to download an archive of the files locally -1. Unzip the archive, then open a terminal and `cd` to the directory you unzipped -1. Install the dependencies with `npm install` -1. Run `npm start` to start a local server and follow the prompts to view the code running in a browser +1. [Node.js](https://nodejs.org/en/) ইনস্টল করতে হবে। +2.আপনি আগে খুলেছিলেন CodeSandbox ট্যাবে, উপরের বাম কোণের বোতামে ক্লিক করুন যাতে মেনু খুলে, এবং তারপর সেই মেনুতে **Download Sandbox** নির্বাচন করুন যাতে ফাইলগুলির একটি আর্কাইভ স্থানীয়ভাবে ডাউনলোড করা যায়। +3. আর্কাইভটি আনজিপ করুন, তারপর একটি টার্মিনাল খুলুন এবং আনজিপ করা ডিরেক্টরিতে `cd` করুন। +4. `npm install` দিয়ে ডিপেন্ডেন্সিগুলি ইনস্টল করুন। +5. লোকাল সার্ভার শুরু করতে `npm start` চালান এবং একটি ব্রাউজারে কোডটি চলমান দেখতে প্রম্পট অনুসরণ করুন। -If you get stuck, don't let this stop you! Follow along online instead and try a local setup again later. +যদি আপনি আটকেও যান, থেমে যাবেন না! পরিবর্তে অনলাইনে অনুসরণ করুন এবং পরে আবার লোকাল সেটআপ করার চেষ্টা করুন। -## Overview {/*overview*/} +## ওভারভিউ {/*overview*/} -Now that you're set up, let's get an overview of React! +যেহেতু আপনার সেটআপ হয়ে গেছে, চলুন রিয়েক্টের একটি ওভারভিউ দেখা যাক! -### Inspecting the starter code {/*inspecting-the-starter-code*/} +### স্টার্টারকোড পর্যবেক্ষন {/*inspecting-the-starter-code*/} -In CodeSandbox you'll see three main sections: +CodeSandbox-এ আপনি তিনটি প্রধান বিভাগ দেখতে পাবেন: ![CodeSandbox with starter code](../images/tutorial/react-starter-code-codesandbox.png) -1. The _Files_ section with a list of files like `App.js`, `index.js`, `styles.css` and a folder called `public` -1. The _code editor_ where you'll see the source code of your selected file -1. The _browser_ section where you'll see how the code you've written will be displayed +1. _ফাইল_ সেকশনে `App.js`, `index.js`, `styles.css` এর মতো ফাইলগুলোর একটি তালিকা এবং `public` নামক একটি ফোল্ডার থাকবে। +2. _কোড এডিটর_ যেখানে আপনি আপনার সিলেক্টেড ফাইলের সোর্স কোড দেখতে পাবেন। +3. _ব্রাউজার_ পার্টে আপনি যে কোডটি লিখেছেন তা কিভাবে প্রদর্শিত হবে তা দেখতে পাবেন। -The `App.js` file should be selected in the _Files_ section. The contents of that file in the _code editor_ should be: +ফাইল সেকশনে `App.js` ফাইলটি নির্বাচিত থাকতে হবে। _কোড এডিটর_ এ সেই ফাইলের বিষয়বস্তু হবে: ```jsx export default function Square() { @@ -295,15 +294,16 @@ export default function Square() { } ``` -The _browser_ section should be displaying a square with a X in it like this: +_ব্রাউজার_ সেকশনটি একটি বর্গক্ষেত্রের মধ্যে X চিহ্ন দেখাচ্ছে, এরকম: ![x-filled square](../images/tutorial/x-filled-square.png) -Now let's have a look at the files in the starter code. +এখন আসুন স্টার্টার কোডের ফাইলগুলোর দিকে নজর দিই। #### `App.js` {/*appjs*/} -The code in `App.js` creates a _component_. In React, a component is a piece of reusable code that represents a part of a user interface. Components are used to render, manage, and update the UI elements in your application. Let's look at the component line by line to see what's going on: +`App.js`-এর কোড একটি _কম্পোনেন্ট_ তৈরি করে। React-এ, একটি কম্পোনেন্ট হলো পুনঃব্যবহারযোগ্য কোডের একটি অংশ, যা একটি ইউজার ইন্টারফেসের একটি অংশকে উপস্থাপন করে। কম্পোনেন্টগুলোকে আপনার অ্যাপ্লিকেশনে UI উপাদানগুলো রেন্ডার, পরিচালনা এবং আপডেট করার জন্য ব্যবহার করা হয়। চলুন লাইন ধরে ধরে দেখি এই কম্পোনেন্টটি কীভাবে কাজ করছে। + ```js {1} export default function Square() { @@ -311,7 +311,7 @@ export default function Square() { } ``` -The first line defines a function called `Square`. The `export` JavaScript keyword makes this function accessible outside of this file. The `default` keyword tells other files using your code that it's the main function in your file. +প্রথম লাইনে `Square` নামের একটি ফাংশন সংজ্ঞায়িত করা হয়েছে। JavaScript এর `export` কিওয়ার্ডটি এই ফাংশনকে এই ফাইলের বাইরে থেকে অ্যাক্সেসযোগ্য করে তোলে। `default` কিওয়ার্ডটি অন্যান্য ফাইলকে জানায় যে এটি আপনার ফাইলে প্রধান ফাংশন: ```js {2} export default function Square() { @@ -319,15 +319,15 @@ export default function Square() { } ``` -The second line returns a button. The `return` JavaScript keyword means whatever comes after is returned as a value to the caller of the function. `` closes the JSX element to indicate that any following content shouldn't be placed inside the button. +দ্বিতীয় লাইনে একটি বাটন রিটার্ন করে। JavaScript এর `return` কিওয়ার্ডটি নির্দেশ করে যে, পরবর্তীতে যা আসবে তা ফাংশনের কলারের জন্য একটি মান হিসেবে ফেরত দেওয়া হবে। `` JSX উপাদানটি বন্ধ করে দেয়, যা নির্দেশ করে যে পরবর্তী কনটেন্টটি বাটনের ভিতরে রাখা উচিত নয়। #### `styles.css` {/*stylescss*/} -Click on the file labeled `styles.css` in the _Files_ section of CodeSandbox. This file defines the styles for your React app. The first two _CSS selectors_ (`*` and `body`) define the style of large parts of your app while the `.square` selector defines the style of any component where the `className` property is set to `square`. In your code, that would match the button from your Square component in the `App.js` file. +_ফাইল_ সেকশনে `styles.css` নামক ফাইলে ক্লিক করুন। এই ফাইলটি আপনার React অ্যাপের স্টাইলগুলি সংজ্ঞায়িত করে। প্রথম দুটি _CSS সিলেক্টর_ (`*` এবং `body`) আপনার অ্যাপের বড় অংশগুলোর স্টাইল নির্ধারণ করে, `.square` সিলেক্টরটি যেকোনো কম্পোনেন্টের স্টাইল নির্ধারণ করে যেখানে `className` প্রপার্টি `square` সেট করা হয়েছে। আপনার কোডে, এটি `App.js` ফাইলে আপনার Square কম্পোনেন্ট থেকে বাটনের সাথে মিলবে। #### `index.js` {/*indexjs*/} -Click on the file labeled `index.js` in the _Files_ section of CodeSandbox. You won't be editing this file during the tutorial but it is the bridge between the component you created in the `App.js` file and the web browser. +_CodeSandbox_এর ফাইল সেকশনে `index.js` নামক ফাইলে ক্লিক করুন। আপনি এই টিউটোরিয়াল চলাকালীন এই ফাইলটি এডিট করবেন না, কিন্তু এটি আপনার তৈরি করা `App.js` ফাইলের কম্পোনেন্ট এবং ওয়েব ব্রাউজারের মধ্যে একটি সেতুর কাজ করে। ```jsx import { StrictMode } from 'react'; @@ -337,20 +337,19 @@ import './styles.css'; import App from './App'; ``` -Lines 1-5 bring all the necessary pieces together: +এই লাইনগুলো সব প্রয়োজনীয় অংশকে একত্রে নিয়ে আসেঃ +- React +- ব্রাউজার(React DOM)এর সাথে ইন্টারাকশন এর জন্য React’s library +- কম্পোনেন্ট এর জন্য স্টাইল +- আপ্পনার তৈরি করা এপ কম্পোনেন্ট `App.js`. -* React -* React's library to talk to web browsers (React DOM) -* the styles for your components -* the component you created in `App.js`. +ফাইলের বাকি অংশ সব টুকরোগুলোকে একত্রিত করে এবং চূড়ান্ত ফলাফল `public` ফোল্ডারের `index.html`-এ অন্তর্ভুক্ত করে। -The remainder of the file brings all the pieces together and injects the final product into `index.html` in the `public` folder. +### বোর্ড তৈরি করা {/*building-the-board*/} -### Building the board {/*building-the-board*/} +চলুন আবার `App.js`-এ ফিরে যাই। এখানে আপনি টিউটোরিয়ালটির বাকি সময় ব্যয় করবেন। -Let's get back to `App.js`. This is where you'll spend the rest of the tutorial. - -Currently the board is only a single square, but you need nine! If you just try and copy paste your square to make two squares like this: +বর্তমানে বোর্ডটি কেবল একটি একক বর্গ, কিন্তু আপনাকে নয়টি বর্গের প্রয়োজন! যদি আপনি কেবল কপি পেস্ট করার চেষ্টা করেন যাতে দুইটি বর্গ হয় এরকম: ```js {2} export default function Square() { @@ -358,7 +357,7 @@ export default function Square() { } ``` -You'll get this error: +তুমি এই এরোরটি দেখবে: @@ -366,7 +365,7 @@ You'll get this error: -React components need to return a single JSX element and not multiple adjacent JSX elements like two buttons. To fix this you can use *Fragments* (`<>` and ``) to wrap multiple adjacent JSX elements like this: +React কম্পোনেন্টগুলিকে একটি একক JSX উপাদান ফেরত দিতে হয় এবং একাধিক পাশাপাশি থাকা JSX উপাদান, যেমন দুটি বোতাম ফেরত দেওয়া যাবে না। এটি ঠিক করতে আপনি _Fragments_ (`<>` এবং ``) ব্যবহার করতে পারেন, যা একাধিক পাশাপাশি থাকা JSX উপাদানগুলিকে এরকমভাবে মোড়াবে: ```js {3-6} export default function Square() { @@ -379,17 +378,17 @@ export default function Square() { } ``` -Now you should see: +এখন এটা দেখা যাবে: ![two x-filled squares](../images/tutorial/two-x-filled-squares.png) -Great! Now you just need to copy-paste a few times to add nine squares and... +দারুণ! এখন আপনাকে কেবল কয়েকবার কপি-পেস্ট করতে হবে যাতে নয়টি স্কয়ার যোগ করা যায় এবং.. ![nine x-filled squares in a line](../images/tutorial/nine-x-filled-squares.png) -Oh no! The squares are all in a single line, not in a grid like you need for our board. To fix this you'll need to group your squares into rows with `div`s and add some CSS classes. While you're at it, you'll give each square a number to make sure you know where each square is displayed. +ওহ না! সব স্কয়ার একটি লাইনেই রয়েছে, বোর্ডের মতো গ্রিডে নেই। এটি ঠিক করতে আপনাকে `div` দিয়ে স্কয়ারগুলোকে সারিতে সাজাতে হবে এবং কিছু CSS ক্লাস যোগ করতে হবে। একইসাথে, আপনি প্রতিটি স্কয়ারকে একটি নম্বর দেবেন, যাতে আপনি জানেন প্রতিটি স্কয়ার কোথায় প্রদর্শিত হচ্ছে। -In the `App.js` file, update the `Square` component to look like this: +`App.js` ফাইলে, `Square` কম্পোনেন্টটি এইভাবে আপডেট করুন: ```js {3-19} export default function Square() { @@ -415,11 +414,11 @@ export default function Square() { } ``` -The CSS defined in `styles.css` styles the divs with the `className` of `board-row`. Now that you've grouped your components into rows with the styled `div`s you have your tic-tac-toe board: +`styles.css`-এ সংজ্ঞায়িত CSS কোড `className` হিসাবে `board-row` যুক্ত div-এর স্টাইল নির্ধারণ করে। এখন আপনি আপনার কম্পোনেন্টগুলোকে স্টাইলযুক্ত `div` দিয়ে সারিতে গোষ্ঠীবদ্ধ করেছেন, ফলে আপনার টিক-ট্যাক-টো বোর্ড তৈরি হয়েছে: ![tic-tac-toe board filled with numbers 1 through 9](../images/tutorial/number-filled-board.png) -But you now have a problem. Your component named `Square`, really isn't a square anymore. Let's fix that by changing the name to `Board`: +কিন্তু এখন আপনার একটি সমস্যা হয়েছে। আপনার `Square` নামে যে কম্পোনেন্টটি আছে, তা আর সত্যিই একটি স্কয়ার নয়। চলুন এটি ঠিক করি নামটি `Board`-এ পরিবর্তন করে: ```js {1} export default function Board() { @@ -427,7 +426,7 @@ export default function Board() { } ``` -At this point your code should look something like this: +এ পর্যায়ে আপনার কোডটি কিছুটা এরকম দেখাবে: @@ -504,15 +503,15 @@ body { -Psssst... That's a lot to type! It's okay to copy and paste code from this page. However, if you're up for a little challenge, we recommend only copying code that you've manually typed at least once yourself. +এটি টাইপ করার জন্য অনেক কিছু! এই পেজ থেকে কোড কপি এবং পেস্ট করা ঠিক আছে। তবে, আপনি যদি একটু চ্যালেঞ্জ নিতে চান, আমরা পরামর্শ দেব যে আপনি শুধুমাত্র সেই কোডটি কপি করুন, যা আপনি অন্তত একবার নিজে হাতে টাইপ করেছেন। -### Passing data through props {/*passing-data-through-props*/} +### Props দিয়ে ডেটা পাঠানো {/*passing-data-through-props*/} -Next, you'll want to change the value of a square from empty to "X" when the user clicks on the square. With how you've built the board so far you would need to copy-paste the code that updates the square nine times (once for each square you have)! Instead of copy-pasting, React's component architecture allows you to create a reusable component to avoid messy, duplicated code. +এবার আপনি চাইবেন, ব্যবহারকারী যখন একটি স্কোয়ারে ক্লিক করবে, সেই স্কোয়ারের মানটি খালি থেকে “X” তে পরিবর্তিত হবে। আপনি যেভাবে বোর্ডটি তৈরি করেছেন, তাতে আপনাকে স্কোয়ারের মান আপডেট করার কোডটি নয়বার (প্রতিটি স্কোয়ারের জন্য একবার করে) কপি-পেস্ট করতে হবে! কপি-পেস্টের পরিবর্তে, React-এর কম্পোনেন্ট আর্কিটেকচার আপনাকে একটি পুনরায় ব্যবহারযোগ্য কম্পোনেন্ট তৈরি করার সুযোগ দেয় যাতে কোডের বিশৃঙ্খল ও পুনরাবৃত্তি এড়ানো যায়। -First, you are going to copy the line defining your first square (``) from your `Board` component into a new `Square` component: +প্রথমে, আপনি আপনার `Board` কম্পোনেন্ট থেকে প্রথম স্কোয়ারের (``) জন্য ডিফাইন করা লাইনটি কপি করে একটি নতুন `Square` কম্পোনেন্টে নিয়ে যাবেন। ```js {1-3} function Square() { @@ -524,7 +523,7 @@ export default function Board() { } ``` -Then you'll update the Board component to render that `Square` component using JSX syntax: +এরপর আপনি `Board` কম্পোনেন্টটি আপডেট করবেন যাতে এটি JSX সিনট্যাক্স ব্যবহার করে সেই `Square` কম্পোনেন্টটি রেন্ডার করে: ```js {5-19} // ... @@ -551,15 +550,15 @@ export default function Board() { } ``` -Note how unlike the browser `div`s, your own components `Board` and `Square` must start with a capital letter. +লক্ষ্য করুন, ব্রাউজারের `div`-এর মতো নয়, আপনার নিজের কম্পোনেন্টগুলো যেমন `Board` এবং `Square` অবশ্যই বড় হাতের অক্ষর দিয়ে শুরু হতে হবে। -Let's take a look: +আসুন একবার দেখে নেই: ![one-filled board](../images/tutorial/board-filled-with-ones.png) -Oh no! You lost the numbered squares you had before. Now each square says "1". To fix this, you will use *props* to pass the value each square should have from the parent component (`Board`) to its child (`Square`). +ওহহো! আপনি আগের নম্বরযুক্ত স্কোয়ারগুলো হারিয়ে ফেলেছেন। এখন প্রতিটি স্কোয়ারই "1" দেখাচ্ছে। এটি ঠিক করার জন্য, আপনি _props_ ব্যবহার করবেন যাতে প্যারেন্ট কম্পোনেন্ট (`Board`) থেকে চাইল্ড কম্পোনেন্টে (`Square`) প্রতিটি স্কোয়ারের মান পাঠানো যায়। -Update the `Square` component to read the `value` prop that you'll pass from the `Board`: +`Square` কম্পোনেন্টটিকে আপডেট করুন যাতে এটি `Board` থেকে পাঠানো `value` প্রপটি পড়ে: ```js {1} function Square({ value }) { @@ -567,9 +566,9 @@ function Square({ value }) { } ``` -`function Square({ value })` indicates the Square component can be passed a prop called `value`. +`function Square({ value })` নির্দেশ করে যে `Square` কম্পোনেন্টে একটি `value` নামে প্রপ পাস করা যেতে পারে। -Now you want to display that `value` instead of `1` inside every square. Try doing it like this: +এখন আপনি প্রতিটি স্কোয়ারের ভিতরে "1"-এর পরিবর্তে সেই `value` প্রদর্শন করতে চান। এটি এইভাবে করার চেষ্টা করুন: ```js {2} function Square({ value }) { @@ -577,11 +576,11 @@ function Square({ value }) { } ``` -Oops, this is not what you wanted: +ওহ না, এটা তো আমরা যা চেয়েছিলাম তা নয়: ![value-filled board](../images/tutorial/board-filled-with-value.png) -You wanted to render the JavaScript variable called `value` from your component, not the word "value". To "escape into JavaScript" from JSX, you need curly braces. Add curly braces around `value` in JSX like so: +আমরা আমাদের কম্পোনেন্ট থেকে `value` নামে জাভাস্ক্রিপ্ট ভ্যারিয়েবলটি রেন্ডার করতে চেয়েছিলাম, “value” শব্দটি নয়। JSX থেকে জাভাস্ক্রিপ্টে "escape" করতে হলে আমাদের কার্লি ব্রেস ব্যবহার করতে হবে। JSX-এ `value` এর চারপাশে কার্লি ব্রেস যোগ করুন এইভাবে: ```js {2} function Square({ value }) { @@ -589,11 +588,11 @@ function Square({ value }) { } ``` -For now, you should see an empty board: +এখন, আমরা একটি খালি বোর্ড দেখতে পাওয়া উচিত: ![empty board](../images/tutorial/empty-board.png) -This is because the `Board` component hasn't passed the `value` prop to each `Square` component it renders yet. To fix it you'll add the `value` prop to each `Square` component rendered by the `Board` component: +এটি হচ্ছে কারণ `Board` কম্পোনেন্টটি এখনও প্রতিটি `Square` কম্পোনেন্টে রেন্ডার করার সময় `value` প্রপটি পাঠায়নি। এটি ঠিক করতে, আপনি `Board` কম্পোনেন্ট দ্বারা রেন্ডার করা প্রতিটি `Square` কম্পোনেন্টে `value` প্রপটি যোগ করবেন: ```js {5-7,10-12,15-17} export default function Board() { @@ -619,11 +618,11 @@ export default function Board() { } ``` -Now you should see a grid of numbers again: +এখন আপনি আবার সংখ্যার একটি গ্রিড দেখতে পাবেন: ![tic-tac-toe board filled with numbers 1 through 9](../images/tutorial/number-filled-board.png) -Your updated code should look like this: +আপনার আপডেট করা কোডটি এরকম দেখতে হওয়া উচিত: @@ -702,9 +701,9 @@ body { -### Making an interactive component {/*making-an-interactive-component*/} +### ইন্টারেক্টিভ কম্পোনেন্ট তৈরি করা {/*making-an-interactive-component*/} -Let's fill the `Square` component with an `X` when you click it. Declare a function called `handleClick` inside of the `Square`. Then, add `onClick` to the props of the button JSX element returned from the `Square`: +যখন আপনি স্কোয়ারটিতে ক্লিক করবেন, তখন `Square` কম্পোনেন্টটিকে একটি `X` দিয়ে পূর্ণ করুন। `Square` এর ভিতরে একটি ফাংশন ঘোষণা করুন যাকে `handleClick` বলা হবে। তারপর, `Square` থেকে ফেরত দেওয়া বাটন JSX উপাদানের প্রপ্সে `onClick` যোগ করুন: ```js {2-4,9} function Square({ value }) { @@ -723,19 +722,19 @@ function Square({ value }) { } ``` -If you click on a square now, you should see a log saying `"clicked!"` in the _Console_ tab at the bottom of the _Browser_ section in CodeSandbox. Clicking the square more than once will log `"clicked!"` again. Repeated console logs with the same message will not create more lines in the console. Instead, you will see an incrementing counter next to your first `"clicked!"` log. +যদি আপনি এখন একটি স্কোয়ারে ক্লিক করেন, তাহলে আপনি _Browser_ সেকশনের নিচে _Console_ ট্যাবে `"clicked!"` লেখা একটি লগ দেখতে পাবেন। একাধিকবার স্কোয়ারটিতে ক্লিক করলে `"clicked!"` আবার লগ হবে। একই বার্তার পুনরাবৃত্তি লগ কনসোলে আরও লাইন তৈরি করবে না। পরিবর্তে, আপনার প্রথম `"clicked!"` লগের পাশে একটি বৃদ্ধি পাওয়া কাউন্টার দেখতে পাবেন। -If you are following this tutorial using your local development environment, you need to open your browser's Console. For example, if you use the Chrome browser, you can view the Console with the keyboard shortcut **Shift + Ctrl + J** (on Windows/Linux) or **Option + ⌘ + J** (on macOS). +যদি আপনি আপনার লোকাল ডেভেলপমেন্ট পরিবেশে এই টিউটোরিয়ালটি অনুসরণ করছেন, তাহলে আপনাকে আপনার ব্রাউজারের কনসোল খুলতে হবে। উদাহরণস্বরূপ, আপনি যদি ক্রোম ব্রাউজার ব্যবহার করেন, তাহলে **Shift + Ctrl + J** (Windows/Linux-এ) অথবা **Option + ⌘ + J** (macOS-এ) কীবোর্ড শর্টকাট ব্যবহার করে কনসোলটি দেখতে পারেন। -As a next step, you want the Square component to "remember" that it got clicked, and fill it with an "X" mark. To "remember" things, components use *state*. +পরবর্তী ধাপে, আপনি চান যে `Square` কম্পোনেন্টটি “মনে রাখুক” যে এটি ক্লিক করা হয়েছে এবং এটি একটি “X” চিহ্ন দিয়ে পূর্ণ করুক। “মনে রাখার” জন্য, কম্পোনেন্টগুলি _state_ ব্যবহার করে। -React provides a special function called `useState` that you can call from your component to let it "remember" things. Let's store the current value of the `Square` in state, and change it when the `Square` is clicked. +React একটি বিশেষ ফাংশন প্রদান করে যার নাম `useState`, যা আপনি আপনার কম্পোনেন্ট থেকে কল করতে পারেন যাতে এটি “মনে রাখে”। চলুন, `Square` এর বর্তমান মানটি স্টেটে সংরক্ষণ করি এবং যখন `Square` ক্লিক করা হয় তখন এটি পরিবর্তন করি। -Import `useState` at the top of the file. Remove the `value` prop from the `Square` component. Instead, add a new line at the start of the `Square` that calls `useState`. Have it return a state variable called `value`: +ফাইলের উপরের দিকে `useState` ইম্পোর্ট করুন। `Square` কম্পোনেন্ট থেকে `value` প্রপটি সরান। পরিবর্তে, `Square` এর শুরুর দিকে একটি নতুন লাইন যোগ করুন যা `useState` কল করে। এটি একটি স্টেট ভেরিয়েবল `value` ফিরিয়ে দেবে: ```js {1,3,4} import { useState } from 'react'; @@ -747,9 +746,9 @@ function Square() { //... ``` -`value` stores the value and `setValue` is a function that can be used to change the value. The `null` passed to `useState` is used as the initial value for this state variable, so `value` here starts off equal to `null`. +`value` মানটি সংরক্ষণ করে এবং `setValue` একটি ফাংশন যা মান পরিবর্তন করতে ব্যবহৃত হতে পারে। `useState`-এ পাঠানো `null` এই স্টেট ভেরিয়েবলের প্রাথমিক মান হিসাবে ব্যবহৃত হয়, তাই এখানে `value` শুরুতে `null` সমান। -Since the `Square` component no longer accepts props anymore, you'll remove the `value` prop from all nine of the Square components created by the Board component: +যেহেতু `Square` কম্পোনেন্টটি এখন আর প্রপস গ্রহণ করে না, আপনি `Board` কম্পোনেন্ট দ্বারা তৈরি সব নয়টি `Square` কম্পোনেন্ট থেকে `value` প্রপটি সরিয়ে ফেলবেন: ```js {6-8,11-13,16-18} // ... @@ -776,7 +775,7 @@ export default function Board() { } ``` -Now you'll change `Square` to display an "X" when clicked. Replace the `console.log("clicked!");` event handler with `setValue('X');`. Now your `Square` component looks like this: +এখন আপনি `Square`-কে ক্লিক করা হলে একটি “X” প্রদর্শন করতে পরিবর্তন করবেন। `console.log("clicked!");` ইভেন্ট হ্যান্ডলারটি `setValue('X');` দিয়ে প্রতিস্থাপন করুন। এখন আপনার `Square` কম্পোনেন্টটি এরকম দেখতে হবে: ```js {5} function Square() { @@ -797,13 +796,13 @@ function Square() { } ``` -By calling this `set` function from an `onClick` handler, you're telling React to re-render that `Square` whenever its `