{"id":799,"date":"2020-01-27T14:35:56","date_gmt":"2020-01-27T14:35:56","guid":{"rendered":"https:\/\/www.webhozz.com\/code\/?p=799"},"modified":"2020-03-31T13:03:25","modified_gmt":"2020-03-31T13:03:25","slug":"react-jsx","status":"publish","type":"post","link":"https:\/\/www.webhozz.com\/code\/react-jsx\/","title":{"rendered":"React JSX"},"content":{"rendered":"\n<h5 class=\"wp-block-heading\">Apa itu JSX?<\/h5>\n\n\n\n<p>JSX adalah singkatan dari JavaScript XML.<\/p>\n\n\n\n<p>JSX memungkinkan kita untuk menulis HTML di React JS.<\/p>\n\n\n\n<p>JSX membuat lebih mudah untuk menulis dan menambahkan HTML di React\nJS.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Kode JSX<\/h5>\n\n\n\n<p>JSX memungkinkan kita untuk menulis elemen HTML dalam JavaScript\ndan menempatkannya di DOM tanpa ada&nbsp;<code>createElement()<\/code>&nbsp; dan atau&nbsp;metode<code> appendChild()<\/code>.<\/p>\n\n\n\n<p>JSX dapat mengubah tag HTML menjadi elemen React.<\/p>\n\n\n\n<p><em>Kamu\ntidak harus menggunakan JSX, tetapi JSX dapat membuat lebih mudah untuk menulis\naplikasi React.<\/em><\/p>\n\n\n\n<p>Mari\nkita tunjukkan dengan dua contoh, yang pertama menggunakan JSX dan yang kedua\ntidakmenggunakan JSX:<\/p>\n\n\n\n<p><em><strong>Contoh 1<\/strong><\/em><\/p>\n\n\n\n<p>JSX:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nconst myelement = &lt;h1&gt;I Love JSX!&lt;\/h1&gt;;\n\nReactDOM.render(myelement, document.getElementById('root'));\n<\/pre><\/div>\n\n\n<p><em><strong>Contoh 2<\/strong><\/em><\/p>\n\n\n\n<p>Tanpa JSX:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nconst myelement = React.createElement('h1', {}, 'I do not use JSX!');\n\nReactDOM.render(myelement, document.getElementById('root'));\n<\/pre><\/div>\n\n\n<p>Seperti\nyang kamu lihat pada contoh pertama, JSX memungkinkan kamu untuk menulis HTML\nsecara langsung dalam kode JavaScript.<\/p>\n\n\n\n<p>JSX\nadalah perpanjangan dari bahasa JavaScript berdasarkan ES6, dan diterjemahkan\nke dalam JavaScript reguler pada saat runtime.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Pernyataan di JSX<\/h5>\n\n\n\n<p>Dengan\nJSX, kamu dapat menulis pernyataan di dalam kurung kurawal&nbsp;<code>{ }<\/code>.<\/p>\n\n\n\n<p>Pernyataan\ndapat berupa variabel React, atau properti, atau pernyataan JavaScript lain\nyang valid.&nbsp;JSX akan menjalankan pernyataan dan mengembalikan hasilnya:<\/p>\n\n\n\n<p><em><strong>Contoh<\/strong><\/em><\/p>\n\n\n\n<p>Jalankan pernyataan &nbsp;<code>5 + 5<\/code>:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nconst myelement = &lt;h1&gt;React is {5 + 5} times better with JSX&lt;\/h1&gt;;\n<\/pre><\/div>\n\n\n<h5 class=\"wp-block-heading\">Memasukkan Blok Besar ke HTML<\/h5>\n\n\n\n<p>Untuk\nmenulis HTML pada beberapa baris, letakkan HTML di dalam tanda kurung:<\/p>\n\n\n\n<p><em><strong>Contoh<\/strong><\/em><\/p>\n\n\n\n<p>Membuat daftar dengan tiga item daftar:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\nconst myelement = (\n  &lt;ul&gt;\n    &lt;li&gt;Apples&lt;\/li&gt;\n    &lt;li&gt;Bananas&lt;\/li&gt;\n    &lt;li&gt;Cherries&lt;\/li&gt;\n  &lt;\/ul&gt;\n);\n<\/pre><\/div>\n\n\n<h5 class=\"wp-block-heading\">Satu Elemen Tingkat Atas<\/h5>\n\n\n\n<p>Kode\nHTML harus dibungkus dengan SATU elemen tingkat atas.<\/p>\n\n\n\n<p>Jadi,\njika Kamu ingin menulis&nbsp;<em>dua<\/em>&nbsp;header,\nkamu harus meletakkannya di dalam elemen induk, seperti sebuah&nbsp;elemen<code> div <\/code><\/p>\n\n\n\n<p><strong>Contoh<\/strong><\/p>\n\n\n\n<p>Bungkus dua header di dalam satu elemen DIV:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\nconst myelement = (\n  &lt;div&gt;\n    &lt;h1&gt;I am a Header.&lt;\/h1&gt;\n    &lt;h1&gt;I am a Header too.&lt;\/h1&gt;\n  &lt;\/div&gt;\n);\n<\/pre><\/div>\n\n\n<p><em>JSX akan menampilkan kesalahan jika HTML\ntidak benar, atau jika HTML melewatkan elemen induk.<\/em><em><\/em><\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Elemen\nHarus Ditutup<\/h5>\n\n\n\n<p>JSX mengikuti aturan\nXML, dan karenanya elemen HTML harus ditutup dengan benar.<\/p>\n\n\n\n<p><em><strong>Contoh<\/strong><\/em><\/p>\n\n\n\n<p>Tutup elemen kosong dengan&nbsp;<code>\/&gt;<\/code><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\nconst myelement = &lt;input type=&quot;text&quot; \/&gt;;\n<\/pre><\/div>\n\n\n<p><em>JSX akan menampilkan kesalahan jika HTML tidak ditutup dengan\nbenar.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apa itu JSX? JSX adalah singkatan dari JavaScript XML. JSX memungkinkan kita untuk menulis HTML di React JS. JSX membuat lebih mudah untuk menulis dan<\/p>\n","protected":false},"author":1,"featured_media":775,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-799","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-reactjs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Belajar React JSX - WebHozz Code<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhozz.com\/code\/react-jsx\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Belajar React JSX - WebHozz Code\" \/>\n<meta property=\"og:description\" content=\"Apa itu JSX? JSX adalah singkatan dari JavaScript XML. JSX memungkinkan kita untuk menulis HTML di React JS. JSX membuat lebih mudah untuk menulis dan\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhozz.com\/code\/react-jsx\/\" \/>\n<meta property=\"og:site_name\" content=\"WebHozz Code\" \/>\n<meta property=\"article:published_time\" content=\"2020-01-27T14:35:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-31T13:03:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhozz.com\/code\/wp-content\/uploads\/2020\/01\/logo-reactjs.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"750\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#\\\/schema\\\/person\\\/04c781607b26b4f4f052684571acc0c6\"},\"headline\":\"React JSX\",\"datePublished\":\"2020-01-27T14:35:56+00:00\",\"dateModified\":\"2020-03-31T13:03:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/\"},\"wordCount\":283,\"image\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/logo-reactjs.jpg\",\"articleSection\":[\"ReactJS\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/\",\"name\":\"Belajar React JSX - WebHozz Code\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/logo-reactjs.jpg\",\"datePublished\":\"2020-01-27T14:35:56+00:00\",\"dateModified\":\"2020-03-31T13:03:25+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#\\\/schema\\\/person\\\/04c781607b26b4f4f052684571acc0c6\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/logo-reactjs.jpg\",\"contentUrl\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/logo-reactjs.jpg\",\"width\":750,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/react-jsx\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React JSX\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#website\",\"url\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/\",\"name\":\"WebHozz Code\",\"description\":\"Tutorial Web &amp; Pemrograman Indonesia\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/#\\\/schema\\\/person\\\/04c781607b26b4f4f052684571acc0c6\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"url\":\"https:\\\/\\\/www.webhozz.com\\\/code\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Belajar React JSX - WebHozz Code","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhozz.com\/code\/react-jsx\/","og_locale":"en_US","og_type":"article","og_title":"Belajar React JSX - WebHozz Code","og_description":"Apa itu JSX? JSX adalah singkatan dari JavaScript XML. JSX memungkinkan kita untuk menulis HTML di React JS. JSX membuat lebih mudah untuk menulis dan","og_url":"https:\/\/www.webhozz.com\/code\/react-jsx\/","og_site_name":"WebHozz Code","article_published_time":"2020-01-27T14:35:56+00:00","article_modified_time":"2020-03-31T13:03:25+00:00","og_image":[{"width":750,"height":400,"url":"https:\/\/www.webhozz.com\/code\/wp-content\/uploads\/2020\/01\/logo-reactjs.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/#article","isPartOf":{"@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/"},"author":{"name":"admin","@id":"https:\/\/www.webhozz.com\/code\/#\/schema\/person\/04c781607b26b4f4f052684571acc0c6"},"headline":"React JSX","datePublished":"2020-01-27T14:35:56+00:00","dateModified":"2020-03-31T13:03:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/"},"wordCount":283,"image":{"@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webhozz.com\/code\/wp-content\/uploads\/2020\/01\/logo-reactjs.jpg","articleSection":["ReactJS"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/","url":"https:\/\/www.webhozz.com\/code\/react-jsx\/","name":"Belajar React JSX - WebHozz Code","isPartOf":{"@id":"https:\/\/www.webhozz.com\/code\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/#primaryimage"},"image":{"@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webhozz.com\/code\/wp-content\/uploads\/2020\/01\/logo-reactjs.jpg","datePublished":"2020-01-27T14:35:56+00:00","dateModified":"2020-03-31T13:03:25+00:00","author":{"@id":"https:\/\/www.webhozz.com\/code\/#\/schema\/person\/04c781607b26b4f4f052684571acc0c6"},"breadcrumb":{"@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhozz.com\/code\/react-jsx\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/#primaryimage","url":"https:\/\/www.webhozz.com\/code\/wp-content\/uploads\/2020\/01\/logo-reactjs.jpg","contentUrl":"https:\/\/www.webhozz.com\/code\/wp-content\/uploads\/2020\/01\/logo-reactjs.jpg","width":750,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhozz.com\/code\/react-jsx\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhozz.com\/code\/"},{"@type":"ListItem","position":2,"name":"React JSX"}]},{"@type":"WebSite","@id":"https:\/\/www.webhozz.com\/code\/#website","url":"https:\/\/www.webhozz.com\/code\/","name":"WebHozz Code","description":"Tutorial Web &amp; Pemrograman Indonesia","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhozz.com\/code\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.webhozz.com\/code\/#\/schema\/person\/04c781607b26b4f4f052684571acc0c6","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bff35e4083f3870e2f911c4437e788147d340f274268d361dd7e1cf20bebb156?s=96&d=mm&r=g","caption":"admin"},"url":"https:\/\/www.webhozz.com\/code\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/posts\/799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/comments?post=799"}],"version-history":[{"count":1,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/posts\/799\/revisions"}],"predecessor-version":[{"id":801,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/posts\/799\/revisions\/801"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/media\/775"}],"wp:attachment":[{"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/media?parent=799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/categories?post=799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhozz.com\/code\/wp-json\/wp\/v2\/tags?post=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}