{"id":2594,"date":"2022-04-22T13:23:35","date_gmt":"2022-04-22T11:23:35","guid":{"rendered":"https:\/\/ekiwi.de\/?p=2594"},"modified":"2022-04-22T13:23:35","modified_gmt":"2022-04-22T11:23:35","slug":"react-bedingte-html-ausgabe-inline","status":"publish","type":"post","link":"https:\/\/ekiwi.de\/index.php\/2594\/react-bedingte-html-ausgabe-inline\/","title":{"rendered":"React: bedingte HTML-Ausgabe (inline)"},"content":{"rendered":"<p>Bedingte Ausgabe in React, ohne eigene Komponente.<\/p>\n<p><!--more--><\/p>\n<p>Bedingte Ausgaben lassen sich durch eigene Komponenten leicht l\u00f6sen, aber nicht immer m\u00f6chte man dieses Fass aufmachen. <\/p>\n<p>Die einfache M\u00f6glichkeit ist direkt eine Bedingung inline aufzunehmen, hier ein Beispiel:<\/p>\n<pre>{this.name.length &gt; 0 &amp;&amp;\r\n&lt;div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}&gt;\r\n    &lt;LabelIcon fontSize=&quot;small&quot; style={{ marginRight: 5 }} \/&gt;\r\n    &lt;span&gt;\r\n        &lt;b&gt;IP:&lt;\/b&gt; {this.name}&lt;br\/&gt;\r\n    &lt;\/span&gt;\r\n&lt;\/div&gt;\r\n}<\/pre>","protected":false},"excerpt":{"rendered":"<p>Bedingte Ausgabe in React, ohne eigene Komponente.<\/p>\n","protected":false},"author":1,"featured_media":2260,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[15],"tags":[44,561],"class_list":["post-2594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-javascript","tag-react"],"_links":{"self":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/2594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/comments?post=2594"}],"version-history":[{"count":0,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/2594\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media\/2260"}],"wp:attachment":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media?parent=2594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/categories?post=2594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/tags?post=2594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}