You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Translate 'Writing Markup with JSX' page to Gujarati
- Complete translation of writing-markup-with-jsx.md
- All explanations, examples, and UI text translated
- Code examples and technical terms preserved
- Maintains original structure and formatting
# JSX સાથે માર્કઅપ લખવું {/*writing-markup-with-jsx*/}
4
2
5
-
<Intro>
6
-
7
-
*JSX* is a syntax extension for JavaScript that lets you write HTML-like markup inside a JavaScript file. Although there are other ways to write components, most React developers prefer the conciseness of JSX, and most codebases use it.
3
+
*JSX* એ JavaScript માટેનું syntax extension છે જે તમને JavaScript ફાઇલની અંદર HTML-જેવું માર્કઅપ લખવાની મંજૂરી આપે છે. React components લખવાની અન્ય રીતો પણ છે, પરંતુ મોટાભાગના React developers JSX ની સુવિધાને પસંદ કરે છે, અને મોટાભાગના codebases તેનો ઉપયોગ કરે છે.
8
4
9
-
</Intro>
5
+
<Intro>
10
6
11
-
<YouWillLearn>
7
+
તમે શીખશો કે:
12
8
13
-
*Why React mixes markup with rendering logic
14
-
*How JSX is different from HTML
15
-
*How to display information with JSX
9
+
* React શા માટે markup અને rendering logic ને મિક્સ કરે છે
10
+
* JSX HTML થી કેવી રીતે અલગ છે
11
+
*JSX સાથે information કેવી રીતે display કરવી
16
12
17
-
</YouWillLearn>
13
+
</Intro>
18
14
19
-
## JSX: Putting markup into JavaScript {/*jsx-putting-markup-into-javascript*/}
15
+
## JSX: JavaScript માં markup મૂકવું {/*jsx-putting-markup-into-javascript*/}
20
16
21
-
The Web has been built on HTML, CSS, and JavaScript. For many years, web developers kept content in HTML, design in CSS, and logic in JavaScript—often in separate files! Content was marked up inside HTML while the page's logic lived separately in JavaScript:
17
+
Web લાંબા સમયથી HTML, CSS અને JavaScript પર બનાવવામાં આવ્યું છે. વર્ષો સુધી, web developers content ને HTML માં, design ને CSS માં, અને logic ને JavaScript માં—ઘણીવાર અલગ ફાઇલોમાં રાખતા હતા! Content HTML ની અંદર markup કરવામાં આવતું હતું જ્યારે page નું logic JavaScript માં અલગથી રહેતું હતું:
22
18
23
19
<DiagramGroup>
24
20
@@ -36,37 +32,33 @@ JavaScript
36
32
37
33
</DiagramGroup>
38
34
39
-
But as the Web became more interactive, logic increasingly determined content. JavaScript was in charge of the HTML! This is why **in React, rendering logic and markup live together in the same place—components.**
35
+
પરંતુ જેમ જેમ Web વધુ interactive બન્યું, તેમ તેમ logic વધુને વધુ content ને નિયંત્રિત કરવા લાગ્યું. JavaScript HTML ના હવાલે હતું! આ કારણથી **React માં, rendering logic અને markup એક જ જગ્યાએ રહે છે—components માં.**
40
36
41
37
<DiagramGroup>
42
38
43
-
<Diagramname="writing_jsx_sidebar"height={330}width={325}alt="React component with HTML and JavaScript from previous examples mixed. Function name is Sidebar which calls the function isLoggedIn, highlighted in yellow. Nested inside the function highlighted in purple is the p tag from before, and a Form tag referencing the component shown in the next diagram.">
39
+
<Diagramname="writing_jsx_sidebar"height={330}width={325}alt="React component with HTML and JavaScript from previous examples mixed. Function name is Sidebar which calls the function isLoggedIn, highlighted in yellow, followed by conditional logic also highlighted in yellow. Nested inside a div highlighted in purple are the tags from before, replaced by three React components: NavLinks, ChatList, ContactList.">
44
40
45
41
`Sidebar.js` React component
46
42
47
43
</Diagram>
48
44
49
-
<Diagramname="writing_jsx_form"height={330}width={325}alt="React component with HTML and JavaScript from previous examples mixed. Function name is Form containing two handlers onClick and onSubmit highlighted in yellow. Following the handlers is HTML highlighted in purple. The HTML contains a form element with a nested input element, each with an onClick prop.">
45
+
<Diagramname="writing_jsx_form"height={330}width={325}alt="React component with HTML and JavaScript from previous examples mixed. Function name is Form highlighted in yellow containing two handlers onClick and onSubmit highlighted in yellow. Following the handlers is HTML highlighted in purple. The HTML contains a form element with a nested input element, both highlighted in purple.">
50
46
51
47
`Form.js` React component
52
48
53
49
</Diagram>
54
50
55
51
</DiagramGroup>
56
52
57
-
Keeping a button's rendering logic and markup together ensures that they stay in sync with each other on every edit. Conversely, details that are unrelated, such as the button's markup and a sidebar's markup, are isolated from each other, making it safer to change either of them on their own.
58
-
59
-
Each React component is a JavaScript function that may contain some markup that React renders into the browser. React components use a syntax extension called JSX to represent that markup. JSX looks a lot like HTML, but it is a bit stricter and can display dynamic information. The best way to understand this is to convert some HTML markup to JSX markup.
53
+
Button ના rendering logic અને markup ને એકસાથે રાખવાથી તેઓ દરેક edit પર એકબીજા સાથે sync માં રહે છે. ઉલટાનું, વિગતો જે સંબંધિત નથી, જેમ કે button નું markup અને sidebar નું markup, એકબીજાથી isolated હોય છે, જેનાથી કોઈપણને બદલવું વધુ સુરક્ષિત બને છે.
60
54
61
-
<Note>
55
+
દરેક React component એક JavaScript function છે જેમાં થોડું markup હોઈ શકે છે જે React browser માં render કરે છે. React components એક syntax extension વાપરે છે જેને JSX કહેવાય છે markup represent કરવા માટે. JSX HTML જેવું દેખાય છે, પરંતુ તે થોડું વધુ strict છે અને dynamic information display કરી શકે છે.
62
56
63
-
JSX and React are two separate things. They're often used together, but you *can*[use them independently](https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#whats-a-jsx-transform) of each other. JSX is a syntax extension, while React is a JavaScript library.
57
+
આ સમજવાનો શ્રેષ્ઠ રસ્તો એ છે કે HTML markup ને JSX markup માં convert કરવો:
64
58
65
-
</Note>
59
+
## HTML ને JSX માં convert કરવું {/*converting-html-to-jsx*/}
66
60
67
-
## Converting HTML to JSX {/*converting-html-to-jsx*/}
68
-
69
-
Suppose that you have some (perfectly valid) HTML:
61
+
ધારો કે તમારી પાસે આ (સંપૂર્ણ valid) HTML છે:
70
62
71
63
```html
72
64
<h1>Hedy Lamarr's Todos</h1>
@@ -82,7 +74,7 @@ Suppose that you have some (perfectly valid) HTML:
82
74
</ul>
83
75
```
84
76
85
-
And you want to put it into your component:
77
+
અને તમે તેને તમારા component માં મૂકવા માંગો છો:
86
78
87
79
```js
88
80
exportdefaultfunctionTodoList() {
@@ -92,15 +84,14 @@ export default function TodoList() {
92
84
}
93
85
```
94
86
95
-
If you copy and paste it as is, it will not work:
96
-
87
+
જો તમે તેને copy અને paste કરશો, તો તે કામ કરશે નહીં:
97
88
98
89
<Sandpack>
99
90
100
91
```js
101
92
exportdefaultfunctionTodoList() {
102
93
return (
103
-
// This doesn't quite work!
94
+
// This doesn't work!
104
95
<h1>Hedy Lamarr's Todos</h1>
105
96
<img
106
97
src="https://i.imgur.com/yXOvdOSs.jpg"
@@ -116,27 +107,23 @@ export default function TodoList() {
116
107
}
117
108
```
118
109
119
-
```css
120
-
img { height: 90px }
121
-
```
122
-
123
110
</Sandpack>
124
111
125
-
This is because JSX is stricter and has a few more rules than HTML! If you read the error messages above, they'll guide you to fix the markup, or you can follow the guide below.
112
+
આ કારણે કે JSX HTML કરતાં વધુ strict છે અને તેના થોડા વધુ નિયમો છે! જો તમે ઉપરના error messages વાંચશો, તો તેઓ તમને markup ને fix કરવા માટે guide કરશે, અથવા તમે નીચેની guide ને follow કરી શકો છો.
126
113
127
114
<Note>
128
115
129
-
Most of the time, React's on-screen error messages will help you find where the problem is. Give them a read if you get stuck!
116
+
મોટાભાગે, React ની on-screen error messages તમને સમસ્યા શોધવામાં મદદ કરશે. જો તમે અટવાઈ જાઓ તો તેને વાંચો!
130
117
131
118
</Note>
132
119
133
-
## The Rules of JSX {/*the-rules-of-jsx*/}
120
+
## JSX ના નિયમો {/*the-rules-of-jsx*/}
134
121
135
-
### 1. Return a single root element {/*1-return-a-single-root-element*/}
122
+
### 1. Single root element return કરો {/*1-return-a-single-root-element*/}
136
123
137
-
To return multiple elements from a component, **wrap them with a single parent tag.**
124
+
Component માંથી multiple elements return કરવા માટે, **તેમને single parent tag સાથે wrap કરો.**
138
125
139
-
For example, you can use a `<div>`:
126
+
ઉદાહરણ તરીકે, તમે `<div>` વાપરી શકો છો:
140
127
141
128
```js {1,11}
142
129
<div>
@@ -152,8 +139,7 @@ For example, you can use a `<div>`:
152
139
</div>
153
140
```
154
141
155
-
156
-
If you don't want to add an extra `<div>` to your markup, you can write `<>` and `</>` instead:
142
+
જો તમે તમારા markup માં extra `<div>` ઉમેરવા નથી માંગતા, તો તમે `<>` અને `</>` લખી શકો છો:
157
143
158
144
```js {1,11}
159
145
<>
@@ -169,21 +155,21 @@ If you don't want to add an extra `<div>` to your markup, you can write `<>` and
169
155
</>
170
156
```
171
157
172
-
This empty tag is called a *[Fragment.](/reference/react/Fragment)* Fragments let you group things without leaving any trace in the browser HTML tree.
158
+
આ empty tag ને *[Fragment](/reference/react/Fragment)* કહેવાય છે. Fragments તમને DOM tree માં કોઈ trace છોડ્યા વિના વસ્તુઓને group કરવાની મંજૂરી આપે છે.
173
159
174
160
<DeepDive>
175
161
176
-
#### Why do multiple JSX tags need to be wrapped? {/*why-do-multiple-jsx-tags-need-to-be-wrapped*/}
162
+
#### JSX ને single tag ની જરૂર શા માટે છે? {/*why-do-multiple-jsx-tags-need-to-be-wrapped*/}
177
163
178
-
JSX looks like HTML, but under the hood it is transformed into plain JavaScript objects. You can't return two objects from a function without wrapping them into an array. This explains why you also can't return two JSX tags without wrapping them into another tag or a Fragment.
164
+
JSX HTML જેવું લાગે છે, પરંતુ તેની અંદર તે plain JavaScript objects માં transform થાય છે. તમે function માંથી બે objects ને array માં wrap કર્યા વિના return કરી શકતા નથી. આ સમજાવે છે કે તમે બે JSX tags ને પણ બીજા tag અથવા Fragment માં wrap કર્યા વિના return કરી શકતા નથી.
179
165
180
166
</DeepDive>
181
167
182
-
### 2. Close all the tags {/*2-close-all-the-tags*/}
JSX requires tags to be explicitly closed: self-closing tags like `<img>` must become `<img />`, and wrapping tags like `<li>oranges` must be written as `<li>oranges</li>`.
170
+
JSX માં બધા tags explicitly બંધ કરવાની જરૂર છે: self-closing tags જેમ કે `<img>` એ `<img />` બનવા જોઈએ, અને wrapping tags જેમ કે `<li>oranges` એ `<li>oranges</li>` તરીકે લખવા જોઈએ.
185
171
186
-
This is how Hedy Lamarr's image and list items look closed:
172
+
આ રીતે Hedy Lamarr નું image અને list items બંધ દેખાય છે:
187
173
188
174
```js {2-6,8-10}
189
175
<>
@@ -200,11 +186,11 @@ This is how Hedy Lamarr's image and list items look closed:
200
186
</>
201
187
```
202
188
203
-
### 3. camelCase <s>all</s> most of the things! {/*3-camelcase-salls-most-of-the-things*/}
189
+
### 3. camelCase લગભગ બધું! {/*3-camelcase-salls-most-of-the-things*/}
204
190
205
-
JSX turns into JavaScript and attributes written in JSX become keys of JavaScript objects. In your own components, you will often want to read those attributes into variables. But JavaScript has limitations on variable names. For example, their names can't contain dashes or be reserved words like `class`.
191
+
JSX JavaScript માં transform થાય છે અને JSX માં લખાયેલા attributes JavaScript objects ની keys બને છે. તમારા પોતાના components માં, તમે ઘણીવાર આ attributes ને variables માં read કરવા માંગશો. પરંતુ JavaScript માં variable names ની limitations છે. ઉદાહરણ તરીકે, તેઓ dashes સમાવી શકતા નથી અથવા `class` જેવા reserved words હોઈ શકતા નથી.
206
192
207
-
This is why, in React, many HTML and SVG attributes are written in camelCase. For example, instead of `stroke-width` you use `strokeWidth`. Since `class` is a reserved word, in React you write `className` instead, named after the [corresponding DOM property](https://developer.mozilla.org/en-US/docs/Web/API/Element/className):
193
+
આ કારણથી, React માં ઘણા HTML અને SVG attributes camelCase માં લખાય છે. ઉદાહરણ તરીકે, `stroke-width` ને બદલે તમે `strokeWidth` વાપરો છો. કારણ કે `class` reserved word છે, React માં તમે તેના બદલે `className` લખો છો, [corresponding DOM property](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) પરથી નામ આપવામાં આવ્યું છે:
208
194
209
195
```js {4}
210
196
<img
@@ -214,19 +200,19 @@ This is why, in React, many HTML and SVG attributes are written in camelCase. Fo
214
200
/>
215
201
```
216
202
217
-
Youcan [findalltheseattributesinthelistofDOMcomponentprops.](/reference/react-dom/components/common)Ifyougetonewrong, don't worry—React will print a message with a possible correction to the [browser console.](https://developer.mozilla.org/docs/Tools/Browser_Console)
203
+
તમે [આ બધા attributes DOM component props reference માં શોધી શકો છો](/reference/react-dom/components/common). જો તમે કોઈ ખોટું કરો છો, તો ચિંતા કરશો નહીં—React browser console માં સુધારાનું સુઝાવ આપે છે.
218
204
219
205
<Pitfall>
220
206
221
-
For historical reasons, [`aria-*`](https://developer.mozilla.org/docs/Web/Accessibility/ARIA) and [`data-*`](https://developer.mozilla.org/docs/Learn/HTML/Howto/Use_data_attributes) attributes are written as in HTML with dashes.
207
+
Historical reasons માટે, [`aria-*`](https://developer.mozilla.org/docs/Web/Accessibility/ARIA) અને [`data-*`](https://developer.mozilla.org/docs/Learn/HTML/Howto/Use_data_attributes) attributes HTML માં હોય તેવા dashes સાથે લખાય છે.
222
208
223
209
</Pitfall>
224
210
225
-
### Pro-tip: Use a JSX Converter {/*pro-tip-use-a-jsx-converter*/}
Converting all these attributes in existing markup can be tedious! We recommend using a [converter](https://transform.tools/html-to-jsx) to translate your existing HTML and SVG to JSX. Converters are very useful in practice, but it'sstillworthunderstandingwhatisgoingonsothatyoucancomfortablywriteJSXonyourown.
213
+
Existing markup માંના આ બધા attributes ને convert કરવું કંટાળાજનક હોઈ શકે છે! અમે existing HTML અને SVG ને JSX માં translate કરવા માટે [converter](https://transform.tools/html-to-jsx) વાપરવાની ભલામણ કરીએ છીએ. Converters practice માં ખૂબ જ ઉપયોગી છે, પરંતુ તમે JSX પર તમારી જાતે comfortably લખી શકો તે માટે શું થઈ રહ્યું છે તે સમજવું હજુ પણ મહત્વપૂર્ણ છે.
228
214
229
-
Hereisyourfinalresult:
215
+
આ તમારું અંતિમ પરિણામ છે:
230
216
231
217
<Sandpack>
232
218
@@ -258,21 +244,19 @@ img { height: 90px }
258
244
259
245
<Recap>
260
246
261
-
NowyouknowwhyJSXexistsandhowtouseitincomponents:
247
+
હવે તમે જાણો છો કે JSX શા માટે અસતિત્વ ધરાવે છે અને components માં તેનો ઉપયોગ કેવી રીતે કરવો:
0 commit comments