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 736065b0..0a05bd3f 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 లో కర్లీ బ్రేసెస్‌తో JavaScript --- -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 మీకు JavaScript ఫైల్ లో HTML లాంటి మార్కప్ రాయడానికి అనుమతిస్తుంది, ఇది రెండరింగ్ లాజిక్ మరియు కంటెంట్‌ను ఒకే చోట ఉంచుతుంది. కొన్ని సందర్భాలలో, మీరు ఆ మార్కప్ లో కొంచెం JavaScript లాజిక్ లేదా డైనమిక్ ప్రాపర్టీని చేర్చాలనుకుంటారు. ఈ పరిస్థితిలో, మీరు JSX లో కర్లీ బ్రేసెస్‌ను ఉపయోగించి JavaScript కి ఒక విండో తెరవచ్చు. -* 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 +* కోట్స్‌ తో strings ను ఎలా పాస్ చేయాలి +* JavaScript వేరియబుల్‌ను JSX లో కర్లీ బ్రేసెస్‌తో ఎలా రిఫరెన్స్ చేయాలి +* JavaScript ఫంక్షన్‌ను JSX లో కర్లీ బ్రేసెస్‌తో ఎలా కాల్ చేయాలి +* JavaScript ఆబ్జెక్ట్‌ను JSX లో కర్లీ బ్రేసెస్‌తో ఎలా ఉపయోగించాలి -## Passing strings with quotes {/*passing-strings-with-quotes*/} +## కోట్స్‌ తో strings ను పాస్ చేయడం {/*passing-strings-with-quotes*/} -When you want to pass a string attribute to JSX, you put it in single or double quotes: +మీరు JSX కు string అట్రిబ్యూట్‌ను పాస్ చేయాలనుకుంటే, మీరు దాన్ని సింగిల్ లేదా డబుల్ కోట్స్‌లో ఉంచాలి: @@ -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"` strings గా పాస్ అవుతున్నాయి. -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` టెక్ట్స్ ను స్పెసిఫై చేయాలనుకుంటే? మీరు **JavaScript నుండి వాల్యూలను ఉపయోగించడానికి `"` మరియు `"` ను `{` మరియు `}` తో మార్చవచ్చు**: @@ -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"` మరియు `src={avatar}` మధ్య తేడాని గమనించండి. `"avatar"` అనేది CSS class పేరు, ఇది చిత్రాన్ని రౌండ్ చేయడానికి ఉపయోగపడుతుంది, కానీ `src={avatar}` అనేది JavaScript వేరియబుల్ `avatar` యొక్క వాల్యూను చదువుతుంది. ఇది ఎందుకంటే కర్లీ బ్రేసెస్ అనేవి JSX లో JavaScript తో పని చేయడాన్ని అనుమతిస్తాయి! -## Using curly braces: A window into the JavaScript world {/*using-curly-braces-a-window-into-the-javascript-world*/} +## కర్లీ బ్రేసెస్ ఉపయోగించడం: JavaScript ప్రపంచంలోకి ఒక విండో {/*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 అనేది JavaScript రాయడానికి ఒక ప్రత్యేకమైన విధానం. అంటే, మీరు అందులో JavaScript ఉపయోగించవచ్చు—కర్లీ బ్రేసెస్ `{ }` తో. క్రింద ఇచ్చిన ఉదాహరణలో, మొదటా శాస్త్రవేత్త పేరు `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()`: +ప్రతి JavaScript ఎక్స్‌ప్రెషన్ కూడా కర్లీ బ్రేసెస్ మధ్య పనిచేస్తుంది, ఉదాహరణకు `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}"`. +1. **టెక్స్ట్ గా** JSX ట్యాగ్ లో నేరుగా: `

{name}'s To Do List

` పనిచేస్తుంది, కానీ `<{tag}>Gregorio Y. Zara's To Do List` పనిచేయదు. +2. **అట్రిబ్యూట్స్ గా** `=` సైన్ వెంటనే: `src={avatar}` అనేది `avatar` వేరియబుల్ ను చదువుతుంది, కానీ `src="{avatar}"` అనేది `"{avatar}"` string ను పాస్ చేస్తుంది. -## Using "double curlies": CSS and other objects in JSX {/*using-double-curlies-css-and-other-objects-in-jsx*/} +## "డబుల్ కర్లీస్" ఉపయోగించడం: JSX లో CSS మరియు ఇతర ఆబ్జెక్టులు {/*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 }}`. +strings, నంబర్స్ మరియు ఇతర JavaScript ఎక్స్‌ప్రెషన్స్‌ ను మించి, మీరు JSX లో ఆబ్జెక్ట్‌లను కూడా పాస్ చేయవచ్చు. ఆబ్జెక్ట్స్‌ను కూడా కర్లీ బ్రేసెస్‌తో చూపిస్తారు, ఉదాహరణకు `{ name: "Hedy Lamarr", inventions: 5 }`. అందువల్ల, JavaScript ఆబ్జెక్ట్‌ను 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: +మీరు దీన్ని JSX లో ఇన్‌లైన్ CSS స్టైల్‌లతో చూడవచ్చు. React ఇన్‌లైన్ స్టైల్‌లను ఉపయోగించమని నిర్దిష్టంగా చెప్పదు (CSS class లు చాలా సందర్భాలలో బాగానే పనిచేస్తాయి). కానీ మీరు ఇన్‌లైన్ స్టైల్ అవసరం ఉన్నప్పుడు, మీరు ఆ `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: +మీరు కర్లీ బ్రేసెస్ లో JavaScript ఆబ్జెక్టును ఇలా రాసినప్పుడు, మీరు ఆ ఆబ్జెక్టును నిజంగా చూడవచ్చు: ```js {2-5}