https://de.wikipedia.org/w/index.php?action=history&feed=atom&title=JSX_%28JavaScript%29 JSX (JavaScript) - Versionsgeschichte 2025-05-24T07:46:50Z Versionsgeschichte dieser Seite in Wikipedia MediaWiki 1.45.0-wmf.2 https://de.wikipedia.org/w/index.php?title=JSX_(JavaScript)&diff=237259537&oldid=prev 2003:DE:371F:DABE:603A:E0BD:BD3F:A182 am 12. September 2023 um 10:54 Uhr 2023-09-12T10:54:12Z <p></p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 12. September 2023, 12:54 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 5:</td> <td colspan="2" class="diff-lineno">Zeile 5:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}}</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>}}</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>'''JSX''' (''JavaScript Syntax Extension'' oder gelegentlich ''JavaScript XML'') ist <del style="font-weight: bold; text-decoration: none;">ein</del> [[Syntax]]-Erweiterung für [[JavaScript]] ([[Syntaktischer Zucker]]).&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt; JSX wurde für das Framework [[React]] entwickelt und wird als [[Auszeichnungssprache]] für [[Steuerelement|Komponenten]] verwendet.</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>'''JSX''' (''JavaScript Syntax Extension'' oder gelegentlich ''JavaScript XML'') ist <ins style="font-weight: bold; text-decoration: none;">eine</ins> [[Syntax]]-Erweiterung für [[JavaScript]] ([[Syntaktischer Zucker]]).&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt; JSX wurde für das Framework [[React]] entwickelt und wird als [[Auszeichnungssprache]] für [[Steuerelement|Komponenten]] verwendet.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Syntax ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Syntax ==</div></td> </tr> </table> 2003:DE:371F:DABE:603A:E0BD:BD3F:A182 https://de.wikipedia.org/w/index.php?title=JSX_(JavaScript)&diff=230193368&oldid=prev Invisigoth67: typo 2023-01-25T10:01:31Z <p>typo</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 25. Januar 2023, 12:01 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 48:</td> <td colspan="2" class="diff-lineno">Zeile 48:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const element = &lt;h1&gt;{title}&lt;/h1&gt;;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const element = &lt;h1&gt;{title}&lt;/h1&gt;;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Standardmäßig entschlüsselt React DOM alle in JSX eingebetteten Werte, bevor sie gerendert werden. Alles wird in eine [[Zeichenkette]] konvertiert, bevor es gerendert wird<del style="font-weight: bold; text-decoration: none;">.</del>.&lt;ref&gt;{{Internetquelle |url=https://www.mariokandut.com/what-is-jsx-in-react/ |titel=What is JSX and why to use it? |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Standardmäßig entschlüsselt React DOM alle in JSX eingebetteten Werte, bevor sie gerendert werden. Alles wird in eine [[Zeichenkette]] konvertiert, bevor es gerendert wird.&lt;ref&gt;{{Internetquelle |url=https://www.mariokandut.com/what-is-jsx-in-react/ |titel=What is JSX and why to use it? |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Props in JSX ===</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Props in JSX ===</div></td> </tr> </table> Invisigoth67 https://de.wikipedia.org/w/index.php?title=JSX_(JavaScript)&diff=228725539&oldid=prev Simon04: erw. 2022-12-10T10:21:35Z <p>erw.</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 10. Dezember 2022, 12:21 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 1:</td> <td colspan="2" class="diff-lineno">Zeile 1:</td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_2_5_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_1_0_lhs"></a>'''JSX''' <del style="font-weight: bold; text-decoration: none;">steht für </del>''<del style="font-weight: bold; text-decoration: none;">Javascript</del> Syntax Extension'' oder ''<del style="font-weight: bold; text-decoration: none;">Javascript</del> XML''<del style="font-weight: bold; text-decoration: none;"> und</del> ist <del style="font-weight: bold; text-decoration: none;">eine</del> [[<del style="font-weight: bold; text-decoration: none;">Erweiterung</del>]] <del style="font-weight: bold; text-decoration: none;">der</del> <del style="font-weight: bold; text-decoration: none;">gängigen Javascript-</del>[[<del style="font-weight: bold; text-decoration: none;">Syntax</del>]] <del style="font-weight: bold; text-decoration: none;">von </del>[[<del style="font-weight: bold; text-decoration: none;">React</del>]].&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>{{Infobox Programmiersprache</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>| Logo = &lt;syntaxhighlight lang="javascript"&gt;const element = &lt;h1&gt;Hallo Welt!&lt;/h1&gt;;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>}}</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_1_0_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_2_5_rhs"></a>'''JSX''' <ins style="font-weight: bold; text-decoration: none;">(</ins>''<ins style="font-weight: bold; text-decoration: none;">JavaScript</ins> Syntax Extension'' oder<ins style="font-weight: bold; text-decoration: none;"> gelegentlich</ins> ''<ins style="font-weight: bold; text-decoration: none;">JavaScript</ins> XML''<ins style="font-weight: bold; text-decoration: none;">)</ins> ist <ins style="font-weight: bold; text-decoration: none;">ein</ins> [[<ins style="font-weight: bold; text-decoration: none;">Syntax</ins>]]<ins style="font-weight: bold; text-decoration: none;">-Erweiterung</ins> <ins style="font-weight: bold; text-decoration: none;">für</ins> [[<ins style="font-weight: bold; text-decoration: none;">JavaScript</ins>]] <ins style="font-weight: bold; text-decoration: none;">(</ins>[[<ins style="font-weight: bold; text-decoration: none;">Syntaktischer Zucker</ins>]]<ins style="font-weight: bold; text-decoration: none;">)</ins>.&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;<ins style="font-weight: bold; text-decoration: none;"> JSX wurde für das Framework [[React]] entwickelt und wird als [[Auszeichnungssprache]] für [[Steuerelement|Komponenten]] verwendet.</ins></div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Syntax ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Syntax ==</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>JSX ist in seiner Syntax ähnlich zu [[Hypertext Markup Language]], wie das folgende Beispiel zeigt:&lt;ref&gt;{{Internetquelle |url=https://facebook.github.io/jsx/ |titel=JSX |werk=facebook.github.io/jsx |datum=2022-08-04 |sprache=en |abruf=2022-12}}&lt;/ref&gt;&lt;syntaxhighlight lang="javascript"&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>In ''JSX'' ist jedes Tag ein „[[Funktion (Programmierung)|Funktionsaufruf]]“, der ein Element erzeugt. Wenn JSX in [[React]] „übersetzt“ wird, sieht das Ergebnis so aus: &lt;syntaxhighlight lang="javascript"&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const user = "Max Mustermann";</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>function createElement(elementType, props, ...children) {}</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const element = (</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Dies liegt daran, dass jedes Tag mit der Funktion &lt;code&gt;createElement()&lt;/code&gt; ein Element erstellt.</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> &lt;div&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> &lt;h1 className="greeting"&gt;Hallo, {user}&lt;/h1&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> &lt;a href="https://www.reactjs.org"&gt;link&lt;/a&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> &lt;/div&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>);</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Beim [[Compiler|Übersetzen]] von JSX wird daraus der folgende React-JavaScript-Code mit erzeugt:&lt;ref&gt;&lt;code&gt;[https://reactjs.org/docs/react-api.html#createelement React.createElement]&lt;/code&gt;&lt;/ref&gt; &lt;syntaxhighlight lang="javascript"&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const user = "Max Mustermann";</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>const element = React.createElement("div", {}, [</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> React.createElement("h1", { className: "greeting" }, ["Hallo, ", user]),</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> React.createElement("a", { href: "https://www.reactjs.org" }, ["link"])</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>]);</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Der folgende Beispielcode zeigt, wie man JSX in [[React]] einbetten kann:&lt;syntaxhighlight lang="javascript"&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker"><a class="mw-diff-movedpara-right" title="Der Absatz wurde verschoben. Klicken, um zur alten Stelle zu springen." href="#movedpara_18_1_lhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_14_0_rhs"></a><ins style="font-weight: bold; text-decoration: none;">Der</ins> <ins style="font-weight: bold; text-decoration: none;">folgende Beispielcode zeigt, wie man JSX in React mittels</ins> &lt;code&gt;ReactDOM.render()&lt;/code&gt; <ins style="font-weight: bold; text-decoration: none;">einbetten</ins> <ins style="font-weight: bold; text-decoration: none;">kann</ins>.&lt;ref&gt;{{Internetquelle |url=https://t3n.de/consent?redirecturl=%2Fnews%2Feigentlich-jsx-wofuer-das-867296%2F |titel=t3n – digital pioneers {{!}} Was ist JSX und wofür braucht man das? |sprache=de |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://www.letsreact.org/what-is-jsx/ |titel=What is JSX? How to use JavaScript with React? – Let's React |sprache=en-US |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref<ins style="font-weight: bold; text-decoration: none;">&gt; &lt;syntaxhighlight lang="javascript"</ins>&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const name = 'Max Mustermann';</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const name = 'Max Mustermann';</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const element = &lt;h1&gt;Hallo, {name}&lt;/h1&gt;;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const element = &lt;h1&gt;Hallo, {name}&lt;/h1&gt;;</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 14:</td> <td colspan="2" class="diff-lineno">Zeile 33:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> document.getElementById('root')</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> document.getElementById('root')</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>);</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>);</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;In diesem Code werden 2 Konstanten erstellt und den Zeichenfolgenwert an den [[Hypertext Markup Language|HTML-Code]] übergeben.</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><br /></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"><a class="mw-diff-movedpara-left" title="Der Absatz wurde verschoben. Klicken, um zur neuen Stelle zu springen." href="#movedpara_14_0_rhs">&#x26AB;</a></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><a name="movedpara_18_1_lhs"></a><del style="font-weight: bold; text-decoration: none;">Danach</del> <del style="font-weight: bold; text-decoration: none;">wird</del> &lt;code&gt;ReactDOM.render()&lt;/code&gt; <del style="font-weight: bold; text-decoration: none;">aufgerufen und den HTML-Code zusammen mit dem „root“-Element</del> <del style="font-weight: bold; text-decoration: none;">übergeben</del>.&lt;ref&gt;{{Internetquelle |url=https://t3n.de/consent?redirecturl=%2Fnews%2Feigentlich-jsx-wofuer-das-867296%2F |titel=t3n – digital pioneers {{!}} Was ist JSX und wofür braucht man das? |sprache=de |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://www.letsreact.org/what-is-jsx/ |titel=What is JSX? How to use JavaScript with React? – Let's React |sprache=en-US |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><br /></td> <td colspan="2" class="diff-empty diff-side-added"></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Attribute ===</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Attribute ===</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Man benutzt meistens Anführungszeichen um string-Literale als Attribute zu verwenden:&lt;syntaxhighlight lang="javascript"&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Man benutzt meistens Anführungszeichen um string-Literale als Attribute zu verwenden:&lt;syntaxhighlight lang="javascript"&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 26:</td> <td colspan="2" class="diff-lineno">Zeile 42:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Sicherheit (XSS) ===</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Sicherheit (XSS) ===</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>JSX verhindert ''Injection-Attacken'' wie XSS. Es ist sicher, Benutzereingaben wie diese einzubetten:&lt;syntaxhighlight lang="javascript"&gt;</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>JSX verhindert ''Injection-Attacken'' wie <ins style="font-weight: bold; text-decoration: none;">[[Cross-Site-Scripting]] (</ins>XSS<ins style="font-weight: bold; text-decoration: none;">)</ins>. Es ist sicher, Benutzereingaben wie diese einzubetten:&lt;syntaxhighlight lang="javascript"&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const title = response.potentiallyMaliciousInput;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const title = response.potentiallyMaliciousInput;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 32:</td> <td colspan="2" class="diff-lineno">Zeile 48:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const element = &lt;h1&gt;{title}&lt;/h1&gt;;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>const element = &lt;h1&gt;{title}&lt;/h1&gt;;</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Standardmäßig entschlüsselt React DOM alle in JSX eingebetteten Werte, bevor sie gerendert werden. Alles wird in <del style="font-weight: bold; text-decoration: none;">einen</del> [[<del style="font-weight: bold; text-decoration: none;">String</del>]] konvertiert, bevor es gerendert wird.<del style="font-weight: bold; text-decoration: none;"> Dies hilft, XSS-Angriffe ([[Cross-Site-Scripting]]) zu verhindern</del>.&lt;ref&gt;{{Internetquelle |url=https://www.mariokandut.com/what-is-jsx-in-react/ |titel=What is JSX and why to use it? |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Standardmäßig entschlüsselt React DOM alle in JSX eingebetteten Werte, bevor sie gerendert werden. Alles wird in <ins style="font-weight: bold; text-decoration: none;">eine</ins> [[<ins style="font-weight: bold; text-decoration: none;">Zeichenkette</ins>]] konvertiert, bevor es gerendert wird..&lt;ref&gt;{{Internetquelle |url=https://www.mariokandut.com/what-is-jsx-in-react/ |titel=What is JSX and why to use it? |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Props in JSX ===</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>=== Props in JSX ===</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Man kann einen beliebigen JavaScript-Ausdruck als ''Prop'' übergeben, indem man ihn mit {} umgibt. Zum Beispiel in diesem Code:&lt;syntaxhighlight lang="javascript"&gt;</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Man kann einen beliebigen JavaScript-Ausdruck als ''Prop'' übergeben, indem man ihn mit <ins style="font-weight: bold; text-decoration: none;">&lt;code&gt;</ins>{}<ins style="font-weight: bold; text-decoration: none;">&lt;/code&gt;</ins> umgibt. Zum Beispiel in diesem Code:&lt;syntaxhighlight lang="javascript"&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;MyComponent foo={1 + 2 + 3 + 4} /&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;MyComponent foo={1 + 2 + 3 + 4} /&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Für &lt;code&gt;MyComponent&lt;/code&gt; wird der Wert von &lt;code&gt;props.foo&lt;/code&gt; 10 sein, weil der Ausdruck 1 + 2 + 3 + 4 ausgewertet wird.</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Für &lt;code&gt;MyComponent&lt;/code&gt; wird der Wert von &lt;code&gt;props.foo&lt;/code&gt; 10 sein, weil der Ausdruck 1 + 2 + 3 + 4 ausgewertet wird.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>''if-Anweisungen'' und ''for-Schleifen'' sind in [[JavaScript]] keine Ausdrücke, daher können sie in JSX nicht direkt verwendet werden.&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/components-and-props.html |titel=Components and Props – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/jsx-in-depth.html |titel=JSX In Depth – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>''if-Anweisungen'' und ''for-Schleifen'' sind in [[JavaScript]] keine Ausdrücke<ins style="font-weight: bold; text-decoration: none;"> (sondern Anweisungen)</ins>, daher können sie in JSX nicht direkt verwendet werden.&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/components-and-props.html |titel=Components and Props – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/jsx-in-depth.html |titel=JSX In Depth – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== Vue ==</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Das Framework [[Vue.js]] verwendet eine eigene Auszeichnungssprache, kann aber auf Wunsch mit JSX verwendet werden.&lt;ref&gt;{{Internetquelle |url=https://vuejs.org/guide/extras/render-function.html#jsx-tsx |titel=Render Functions &amp; JSX |werk=Vue.js |sprache=en |abruf=2022-12}}&lt;/ref&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>== TSX ==</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Zur Verwendung von JSX mit [[TypeScript]] wird die [[Dateierweiterung]] &lt;code&gt;.tsx&lt;/code&gt; verwendet.&lt;ref&gt;{{Internetquelle |url=https://www.typescriptlang.org/docs/handbook/jsx.html |titel=JSX |werk=TypeScript Handbook |sprache=en |abruf=2022-12}}&lt;/ref&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Siehe auch ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Siehe auch ==</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* [[JavaScript]]</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* [[JavaScript<ins style="font-weight: bold; text-decoration: none;">]] und [[TypeScript</ins>]]</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* [[React]]</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* [[React]]</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* [[ECMAScript for XML]]</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Einzelnachweise ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Einzelnachweise ==</div></td> </tr> </table> Simon04 https://de.wikipedia.org/w/index.php?title=JSX_(JavaScript)&diff=226843012&oldid=prev Aka: typografische Anführungszeichen, Kleinkram 2022-10-07T15:01:28Z <p>typografische Anführungszeichen, Kleinkram</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 7. Oktober 2022, 17:01 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 2:</td> <td colspan="2" class="diff-lineno">Zeile 2:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Syntax ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Syntax ==</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>In ''JSX'' ist jedes Tag ein „[[Funktion (Programmierung)|Funktionsaufruf]]“, der ein Element erzeugt. Wenn JSX in [[React]] <del style="font-weight: bold; text-decoration: none;">"übersetzt"</del> wird, sieht das Ergebnis so aus: &lt;syntaxhighlight lang="javascript"&gt;</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>In ''JSX'' ist jedes Tag ein „[[Funktion (Programmierung)|Funktionsaufruf]]“, der ein Element erzeugt. Wenn JSX in [[React]] <ins style="font-weight: bold; text-decoration: none;">„übersetzt“</ins> wird, sieht das Ergebnis so aus: &lt;syntaxhighlight lang="javascript"&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>function createElement(elementType, props, ...children) {}</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>function createElement(elementType, props, ...children) {}</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Dies liegt daran, dass jedes Tag mit der Funktion &lt;code&gt;createElement()&lt;/code&gt; ein Element erstellt.<del style="font-weight: bold; text-decoration: none;"> </del></div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Dies liegt daran, dass jedes Tag mit der Funktion &lt;code&gt;createElement()&lt;/code&gt; ein Element erstellt.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Der folgende Beispielcode zeigt, wie man JSX in [[React]] einbetten kann:&lt;syntaxhighlight lang="javascript"&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Der folgende Beispielcode zeigt, wie man JSX in [[React]] einbetten kann:&lt;syntaxhighlight lang="javascript"&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 14:</td> <td colspan="2" class="diff-lineno">Zeile 14:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> document.getElementById('root')</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> document.getElementById('root')</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>);</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>);</div></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;In diesem Code werden 2 Konstanten erstellt und den Zeichenfolgenwert an den [[Hypertext Markup Language|HTML-Code]] übergeben.<del style="font-weight: bold; text-decoration: none;"> </del></div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;In diesem Code werden 2 Konstanten erstellt und den Zeichenfolgenwert an den [[Hypertext Markup Language|HTML-Code]] übergeben.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Danach wird &lt;code&gt;ReactDOM.render()&lt;/code&gt; aufgerufen und den HTML-Code zusammen mit dem „root“-Element übergeben.&lt;ref&gt;{{Internetquelle |url=https://t3n.de/consent?redirecturl=%2Fnews%2Feigentlich-jsx-wofuer-das-867296%2F |titel=t3n – digital pioneers {{!}} Was ist JSX und wofür braucht man das? |sprache=de |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://www.letsreact.org/what-is-jsx/ |titel=What is JSX? How to use JavaScript with React? – Let's React |sprache=en-US |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>Danach wird &lt;code&gt;ReactDOM.render()&lt;/code&gt; aufgerufen und den HTML-Code zusammen mit dem „root“-Element übergeben.&lt;ref&gt;{{Internetquelle |url=https://t3n.de/consent?redirecturl=%2Fnews%2Feigentlich-jsx-wofuer-das-867296%2F |titel=t3n – digital pioneers {{!}} Was ist JSX und wofür braucht man das? |sprache=de |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://www.letsreact.org/what-is-jsx/ |titel=What is JSX? How to use JavaScript with React? – Let's React |sprache=en-US |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-lineno">Zeile 39:</td> <td colspan="2" class="diff-lineno">Zeile 39:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Für &lt;code&gt;MyComponent&lt;/code&gt; wird der Wert von &lt;code&gt;props.foo&lt;/code&gt; 10 sein, weil der Ausdruck 1 + 2 + 3 + 4 ausgewertet wird.</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;/syntaxhighlight&gt;Für &lt;code&gt;MyComponent&lt;/code&gt; wird der Wert von &lt;code&gt;props.foo&lt;/code&gt; 10 sein, weil der Ausdruck 1 + 2 + 3 + 4 ausgewertet wird.</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>''if-Anweisungen'' und ''for-Schleifen'' sind in [[JavaScript]] keine Ausdrücke, daher können sie in JSX nicht direkt verwendet werden.&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/components-and-props.html |titel=Components and Props – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/jsx-in-depth.html |titel=JSX In Depth – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;<del style="font-weight: bold; text-decoration: none;"> </del></div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>''if-Anweisungen'' und ''for-Schleifen'' sind in [[JavaScript]] keine Ausdrücke, daher können sie in JSX nicht direkt verwendet werden.&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/components-and-props.html |titel=Components and Props – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/jsx-in-depth.html |titel=JSX In Depth – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Siehe auch ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Siehe auch ==</div></td> </tr> </table> Aka https://de.wikipedia.org/w/index.php?title=JSX_(JavaScript)&diff=223585911&oldid=prev M2k~dewiki: HC: Entferne Kategorie:Javascript; Ergänze Kategorie:JavaScript-Bibliothek 2022-06-10T07:46:44Z <p><a href="/wiki/Wikipedia:HC" class="mw-redirect" title="Wikipedia:HC">HC</a>: Entferne <a href="/w/index.php?title=Kategorie:Javascript&amp;action=edit&amp;redlink=1" class="new" title="Kategorie:Javascript (Seite nicht vorhanden)">Kategorie:Javascript</a>; Ergänze <a href="/wiki/Kategorie:JavaScript-Bibliothek" title="Kategorie:JavaScript-Bibliothek">Kategorie:JavaScript-Bibliothek</a></p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 10. Juni 2022, 09:46 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 49:</td> <td colspan="2" class="diff-lineno">Zeile 49:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;references /&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;references /&gt;</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td class="diff-marker" data-marker="−"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>[[Kategorie:<del style="font-weight: bold; text-decoration: none;">Javascript</del>]]</div></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Kategorie:<ins style="font-weight: bold; text-decoration: none;">JavaScript-Bibliothek</ins>]]</div></td> </tr> </table> M2k~dewiki https://de.wikipedia.org/w/index.php?title=JSX_(JavaScript)&diff=223585907&oldid=prev M2k~dewiki: HC: Ergänze Kategorie:Javascript 2022-06-10T07:46:26Z <p><a href="/wiki/Wikipedia:HC" class="mw-redirect" title="Wikipedia:HC">HC</a>: Ergänze <a href="/w/index.php?title=Kategorie:Javascript&amp;action=edit&amp;redlink=1" class="new" title="Kategorie:Javascript (Seite nicht vorhanden)">Kategorie:Javascript</a></p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <col class="diff-marker" /> <col class="diff-content" /> <col class="diff-marker" /> <col class="diff-content" /> <tr class="diff-title" lang="de"> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Version vom 10. Juni 2022, 09:46 Uhr</td> </tr><tr> <td colspan="2" class="diff-lineno">Zeile 48:</td> <td colspan="2" class="diff-lineno">Zeile 48:</td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Einzelnachweise ==</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Einzelnachweise ==</div></td> </tr> <tr> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;references /&gt;</div></td> <td class="diff-marker"></td> <td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>&lt;references /&gt;</div></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><br /></td> </tr> <tr> <td colspan="2" class="diff-empty diff-side-deleted"></td> <td class="diff-marker" data-marker="+"></td> <td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>[[Kategorie:Javascript]]</div></td> </tr> </table> M2k~dewiki https://de.wikipedia.org/w/index.php?title=JSX_(JavaScript)&diff=223584426&oldid=prev Sky-Dean Dawid: Sky-Dean Dawid verschob die Seite Benutzer:Sky-Dean Dawid/JSX (JavaScript) nach JSX (JavaScript): Artikel vollständig 2022-06-10T06:35:10Z <p>Sky-Dean Dawid verschob die Seite <a href="/w/index.php?title=Benutzer:Sky-Dean_Dawid/JSX_(JavaScript)&amp;action=edit&amp;redlink=1" class="new" title="Benutzer:Sky-Dean Dawid/JSX (JavaScript) (Seite nicht vorhanden)">Benutzer:Sky-Dean Dawid/JSX (JavaScript)</a> nach <a href="/wiki/JSX_(JavaScript)" title="JSX (JavaScript)">JSX (JavaScript)</a>: Artikel vollständig</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <tr class="diff-title" lang="de"> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Nächstältere Version</td> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Version vom 10. Juni 2022, 08:35 Uhr</td> </tr><tr><td colspan="2" class="diff-notice" lang="de"><div class="mw-diff-empty">(kein Unterschied)</div> </td></tr></table> Sky-Dean Dawid https://de.wikipedia.org/w/index.php?title=JSX_(JavaScript)&diff=223584415&oldid=prev Sky-Dean Dawid: Artikel fertig. 2022-06-10T06:34:18Z <p>Artikel fertig.</p> <p><b>Neue Seite</b></p><div>&#039;&#039;&#039;JSX&#039;&#039;&#039; steht für &#039;&#039;Javascript Syntax Extension&#039;&#039; oder &#039;&#039;Javascript XML&#039;&#039; und ist eine [[Erweiterung]] der gängigen Javascript-[[Syntax]] von [[React]].&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;<br /> <br /> == Syntax ==<br /> In &#039;&#039;JSX&#039;&#039; ist jedes Tag ein „[[Funktion (Programmierung)|Funktionsaufruf]]“, der ein Element erzeugt. Wenn JSX in [[React]] &quot;übersetzt&quot; wird, sieht das Ergebnis so aus: &lt;syntaxhighlight lang=&quot;javascript&quot;&gt;<br /> function createElement(elementType, props, ...children) {}<br /> &lt;/syntaxhighlight&gt;Dies liegt daran, dass jedes Tag mit der Funktion &lt;code&gt;createElement()&lt;/code&gt; ein Element erstellt. <br /> <br /> Der folgende Beispielcode zeigt, wie man JSX in [[React]] einbetten kann:&lt;syntaxhighlight lang=&quot;javascript&quot;&gt;<br /> const name = &#039;Max Mustermann&#039;;<br /> const element = &lt;h1&gt;Hallo, {name}&lt;/h1&gt;;<br /> <br /> ReactDOM.render(<br /> element,<br /> document.getElementById(&#039;root&#039;)<br /> );<br /> &lt;/syntaxhighlight&gt;In diesem Code werden 2 Konstanten erstellt und den Zeichenfolgenwert an den [[Hypertext Markup Language|HTML-Code]] übergeben. <br /> <br /> Danach wird &lt;code&gt;ReactDOM.render()&lt;/code&gt; aufgerufen und den HTML-Code zusammen mit dem „root“-Element übergeben.&lt;ref&gt;{{Internetquelle |url=https://t3n.de/consent?redirecturl=%2Fnews%2Feigentlich-jsx-wofuer-das-867296%2F |titel=t3n – digital pioneers {{!}} Was ist JSX und wofür braucht man das? |sprache=de |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://www.letsreact.org/what-is-jsx/ |titel=What is JSX? How to use JavaScript with React? – Let&#039;s React |sprache=en-US |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://de.reactjs.org/docs/introducing-jsx.html |titel=Einführung in JSX – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;<br /> <br /> === Attribute ===<br /> Man benutzt meistens Anführungszeichen um string-Literale als Attribute zu verwenden:&lt;syntaxhighlight lang=&quot;javascript&quot;&gt;<br /> const element = &lt;a href=&quot;https://www.wikipedia.org&quot;&gt; link &lt;/a&gt;;<br /> &lt;/syntaxhighlight&gt;Ebenfalls kann man geschweifte Klammern verwenden, um JavaScript-Ausdrücke in ein Attribut einzubinden:&lt;syntaxhighlight lang=&quot;javascript&quot;&gt;<br /> const element = &lt;img src={user.avatarUrl}&gt;&lt;/img&gt;;<br /> &lt;/syntaxhighlight&gt;<br /> <br /> === Sicherheit (XSS) ===<br /> JSX verhindert &#039;&#039;Injection-Attacken&#039;&#039; wie XSS. Es ist sicher, Benutzereingaben wie diese einzubetten:&lt;syntaxhighlight lang=&quot;javascript&quot;&gt;<br /> const title = response.potentiallyMaliciousInput;<br /> <br /> // Dies ist sicher:<br /> <br /> const element = &lt;h1&gt;{title}&lt;/h1&gt;;<br /> &lt;/syntaxhighlight&gt;Standardmäßig entschlüsselt React DOM alle in JSX eingebetteten Werte, bevor sie gerendert werden. Alles wird in einen [[String]] konvertiert, bevor es gerendert wird. Dies hilft, XSS-Angriffe ([[Cross-Site-Scripting]]) zu verhindern.&lt;ref&gt;{{Internetquelle |url=https://www.mariokandut.com/what-is-jsx-in-react/ |titel=What is JSX and why to use it? |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;<br /> <br /> === Props in JSX ===<br /> Man kann einen beliebigen JavaScript-Ausdruck als &#039;&#039;Prop&#039;&#039; übergeben, indem man ihn mit {} umgibt. Zum Beispiel in diesem Code:&lt;syntaxhighlight lang=&quot;javascript&quot;&gt;<br /> &lt;MyComponent foo={1 + 2 + 3 + 4} /&gt;<br /> &lt;/syntaxhighlight&gt;Für &lt;code&gt;MyComponent&lt;/code&gt; wird der Wert von &lt;code&gt;props.foo&lt;/code&gt; 10 sein, weil der Ausdruck 1 + 2 + 3 + 4 ausgewertet wird.<br /> <br /> &#039;&#039;if-Anweisungen&#039;&#039; und &#039;&#039;for-Schleifen&#039;&#039; sind in [[JavaScript]] keine Ausdrücke, daher können sie in JSX nicht direkt verwendet werden.&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/components-and-props.html |titel=Components and Props – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt;&lt;ref&gt;{{Internetquelle |url=https://reactjs.org/docs/jsx-in-depth.html |titel=JSX In Depth – React |sprache=en |abruf=2022-06-10}}&lt;/ref&gt; <br /> <br /> == Siehe auch ==<br /> <br /> * [[JavaScript]]<br /> * [[React]]<br /> <br /> == Einzelnachweise ==<br /> &lt;references /&gt;</div> Sky-Dean Dawid