From fa809da9443ece95e37b277d4340e51103424877 Mon Sep 17 00:00:00 2001 From: nasirmausd Date: Mon, 28 Oct 2024 10:30:28 +0600 Subject: [PATCH 1/7] Tutorial: Tic-Tac-Toe --- src/content/learn/tutorial-tic-tac-toe.md | 454 +++++++++++----------- 1 file changed, 226 insertions(+), 228 deletions(-) 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 `