{"id":1591,"date":"2018-03-01T08:04:26","date_gmt":"2018-03-01T13:04:26","guid":{"rendered":"http:\/\/bluegalaxy.info\/codewalk\/?p=1591"},"modified":"2019-04-21T00:01:48","modified_gmt":"2019-04-21T05:01:48","slug":"react-js-create-simplest-app","status":"publish","type":"post","link":"https:\/\/bluegalaxy.info\/codewalk\/2018\/03\/01\/react-js-create-simplest-app\/","title":{"rendered":"React: How to create the simplest app using Codepen"},"content":{"rendered":"<p>One easy way to create React apps is to use Codepen. Using Codepen to practice creating React apps requires you to first\u00a0 set some JS settings. The JavaScript Preprocessor should\u00a0 be set to Babel because we will be using JSX instead of pure JavaScript. The Quick-add select menu can be used to select both the react.development.js and react-dom.development.js resources. (These will be added to the head of the HTML as CDNs). For example:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" id=\"img_ds\" class=\"alignnone wp-image-1593\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2018\/02\/codepen-react-js-settings.png\" alt=\"\" width=\"507\" height=\"494\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2018\/02\/codepen-react-js-settings.png 641w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2018\/02\/codepen-react-js-settings-300x292.png 300w\" sizes=\"auto, (max-width: 507px) 100vw, 507px\" \/><\/p>\n<p>With these resources set, I will describe how to make the simplest possible React app.<\/p>\n<h3>Step 1: HTML<\/h3>\n<p>In the HTML, we simply need to create a div container for our app output. It can be named anything you want. In this case, I named my div &#8220;chris&#8221;. For example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;div id=\"chris\"&gt;\r\n&lt;!-- React will render view data here   --&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>This div id will be referred to by React.<\/p>\n<p>&nbsp;<\/p>\n<h3>Step 2: JavaScript<\/h3>\n<p>In the JavaScript portion of the code, we will be calling the ReactDOM\u00a0<code class=\"EnlighterJSRAW\" data-enlighter-language=\"no-highlight\">render()<\/code>function. This function takes two arguments:<\/p>\n<p>1. The HTML (or view) to be rendered.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">&lt;h1&gt;Simplest React&lt;\/h1&gt;<\/code><\/p>\n<p>2. The JavaScript for targeting our div id.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">document.getElementById('chris')<\/code><\/p>\n<p>For example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">ReactDOM.render(\r\n  &lt;h1&gt;Simplest React&lt;\/h1&gt;, \r\n  document.getElementById('chris')\r\n);<\/pre>\n<p>Notice the first argument to the render function looks like pure HTML and not JavaScript. This is possible because we are using JSX, which is transpiled by Babel, rather than pure JavaScript.<\/p>\n<p>Here is what the project looks like on codepen:<\/p>\n<p class='codepen'  data-height='265' data-theme-id='0' data-slug-hash='MQZNJE' data-default-tab='js,result' data-animations='run' data-editable='' data-embed-version='2'>\nSee the Pen Simplest React by Chris Nielsen (@Chris_Nielsen) on CodePen.<\/p>\n\n<p>For more information about getting started with React, see:<br \/>\n<a href=\"https:\/\/reactjs.org\/docs\/hello-world.html\">https:\/\/reactjs.org\/docs\/hello-world.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One easy way to create React apps is to use Codepen. Using Codepen to practice creating React apps requires you to first\u00a0 set some JS settings. The JavaScript Preprocessor should\u00a0 be set to Babel because we will be using JSX instead of pure JavaScript. The Quick-add select menu can be used to select both the &hellip; <a href=\"https:\/\/bluegalaxy.info\/codewalk\/2018\/03\/01\/react-js-create-simplest-app\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">React: How to create the simplest app using Codepen<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[44,111],"tags":[45,110],"class_list":["post-1591","post","type-post","status-publish","format-standard","hentry","category-javascript-language","category-react-js","tag-javascript","tag-react-js"],"_links":{"self":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/1591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/comments?post=1591"}],"version-history":[{"count":16,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/1591\/revisions"}],"predecessor-version":[{"id":2564,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/1591\/revisions\/2564"}],"wp:attachment":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/media?parent=1591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/categories?post=1591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/tags?post=1591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}