{"id":32911,"date":"2024-11-01T09:12:25","date_gmt":"2024-11-01T09:12:25","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32911"},"modified":"2024-11-01T11:21:30","modified_gmt":"2024-11-01T11:21:30","slug":"react-course-diary-app-example-implementing-the-home-page","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32911\/","title":{"rendered":"React Course: Diary App Example, Implementing the Home Page"},"content":{"rendered":"<p>React is a library widely used for building dynamic user interfaces. In this course, we will explore the basic concepts of React by creating a diary app. Along the way, we will also implement the Home page. The Home page will be the main screen where users can access the diary and write new entries. In this article, you will learn various techniques, including React\u2019s component structure, state management, and routing.<\/p>\n<h2>1. Basic Concepts of React<\/h2>\n<p>React is a component-based library with user-defined components. Components are independent pieces of the UI, and each component can have state and props. In this course, we will cover key concepts of React, including JSX, components, props, state, and lifecycle.<\/p>\n<h3>1.1 JSX<\/h3>\n<p>JSX stands for JavaScript XML and allows you to include HTML-like syntax within your JavaScript code. Using JSX makes it intuitive to write UI components. JSX is converted to JavaScript objects during compilation.<\/p>\n<pre><code>const element = &lt;h1&gt;Hello, React!&lt;\/h1&gt;;<\/code><\/pre>\n<h3>1.2 Components<\/h3>\n<p>The basic building blocks of React are components. Components can be divided into functional components and class components. We will mostly use functional components.<\/p>\n<pre><code>function Greeting(props) {\n  return &lt;h1&gt;Hello, {props.name}!&lt;\/h1&gt;;\n}<\/code><\/pre>\n<h3>1.3 Props and State<\/h3>\n<p>Props are read-only data passed to components. On the other hand, state is mutable data managed within a component, directly affecting the UI when it changes.<\/p>\n<pre><code>class Example extends React.Component {\n  constructor(props) {\n    super(props);\n    this.state = { count: 0 };\n  }\n\n  render() {\n    return &lt;h1&gt;Current Count: {this.state.count}&lt;\/h1&gt;;\n  }\n}<\/code><\/pre>\n<h3>1.4 Lifecycle<\/h3>\n<p>React components have a lifecycle, and through this lifecycle, you can manage the creation, updating, and removal of components. Key lifecycle methods include componentDidMount, componentDidUpdate, and componentWillUnmount.<\/p>\n<h2>2. Designing the Diary App<\/h2>\n<p>Now, let&#8217;s start designing the diary app. The diary app should have features that allow users to write, edit, and delete diary entries. Additionally, users should be able to view their entries in a list format.<\/p>\n<h3>2.1 App Structure<\/h3>\n<p>The diary app can be divided into the following components:<\/p>\n<ul>\n<li>Home: A screen that includes the diary list and a button to add a new entry<\/li>\n<li>DiaryEntry: A component that displays each diary item<\/li>\n<li>AddEntry: A component that includes a form to write a new diary<\/li>\n<\/ul>\n<h2>3. Implementing the Home Page<\/h2>\n<p>Now let\u2019s implement the Home page. The Home page will include the diary list and a button to add a new diary entry. For this, we will create two components: the Home component and the DiaryEntry component.<\/p>\n<h3>3.1 Home Component<\/h3>\n<pre><code>import React, { useState } from 'react';\nimport DiaryEntry from '.\/DiaryEntry';\nimport AddEntry from '.\/AddEntry';\n\nfunction Home() {\n  const [entries, setEntries] = useState([]);\n\n  const addEntry = (entry) =&gt; {\n    setEntries([...entries, entry]);\n  };\n\n  return (\n    &lt;div&gt;\n      &lt;h1&gt;My Diary&lt;\/h1&gt;\n      &lt;AddEntry onAdd={addEntry} \/&gt;\n      &lt;ul&gt;\n        {entries.map((entry, index) =&gt; (\n          &lt;DiaryEntry key={index} entry={entry} \/&gt;\n        ))}\n      &lt;\/ul&gt;\n    &lt;\/div&gt;\n  );\n}\n\nexport default Home;<\/code><\/pre>\n<h3>3.2 DiaryEntry Component<\/h3>\n<pre><code>import React from 'react';\n\nfunction DiaryEntry({ entry }) {\n  return (\n    &lt;li&gt;\n      &lt;h2&gt;{entry.title}&lt;\/h2&gt;\n      &lt;p&gt;{entry.content}&lt;\/p&gt;\n    &lt;\/li&gt;\n  );\n}\n\nexport default DiaryEntry;<\/code><\/pre>\n<h3>3.3 AddEntry Component<\/h3>\n<pre><code>import React, { useState } from 'react';\n\nfunction AddEntry({ onAdd }) {\n  const [title, setTitle] = useState('');\n  const [content, setContent] = useState('');\n\n  const handleSubmit = (e) =&gt; {\n    e.preventDefault();\n    onAdd({ title, content });\n    setTitle('');\n    setContent('');\n  };\n\n  return (\n    &lt;form onSubmit={handleSubmit}&gt;\n      &lt;input \n        type=\"text\" \n        value={title} \n        onChange={(e) =&gt; setTitle(e.target.value)} \n        placeholder=\"Title\" \n      \/&gt;\n      &lt;textarea \n        value={content} \n        onChange={(e) =&gt; setContent(e.target.value)} \n        placeholder=\"Diary Content\" \n      \/&gt;\n      &lt;button type=\"submit\"&gt;Add Diary&lt;\/button&gt;\n    &lt;\/form&gt;\n  );\n}\n\nexport default AddEntry;<\/code><\/pre>\n<h2>4. Complete App Code<\/h2>\n<p>Now, let\u2019s assemble all the components to build the complete app. We will create an index.js file under the src directory.<\/p>\n<pre><code>import React from 'react';\nimport ReactDOM from 'react-dom\/client';\nimport Home from '.\/Home';\n\nconst root = ReactDOM.createRoot(document.getElementById('root'));\nroot.render(&lt;Home \/&gt;);<\/code><\/pre>\n<h2>5. Conclusion<\/h2>\n<p>In this React course, we learned the basic concepts of React and component-based design through the diary app. By implementing the Home page, we also gained an understanding of state management and how to pass props. Remember that React allows you to easily create user-friendly UIs!<\/p>\n<p>Continue to explore advanced concepts of React by adding more features. Incorporating functionalities such as routing to other pages and saving\/loading data will create a more complete app. Thank you!<\/p>\n<style>\n  h1 {\n    font-size: 2em;\n    color: #4CAF50;\n  }\n  h2 {\n    font-size: 1.5em;\n    color: #2196F3;\n  }\n  h3 {\n    font-size: 1.25em;\n    color: #673AB7;\n  }\n  p {\n    line-height: 1.6;\n  }\n  ul {\n    list-style-type: square;\n    margin-left: 20px;\n  }\n  pre {\n    background-color: #f4f4f4;\n    padding: 10px;\n    border-radius: 5px;\n  }\n  code {\n    font-family: monospace;\n  }\n<\/style>\n","protected":false},"excerpt":{"rendered":"<p>React is a library widely used for building dynamic user interfaces. In this course, we will explore the basic concepts of React by creating a diary app. Along the way, we will also implement the Home page. The Home page will be the main screen where users can access the diary and write new entries. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32911\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;React Course: Diary App Example, Implementing the Home Page&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[123],"tags":[],"class_list":["post-32911","post","type-post","status-publish","format-standard","hentry","category-react-basics-course"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>React Course: Diary App Example, Implementing the Home Page - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/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:\/\/atmokpo.com\/w\/32911\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React Course: Diary App Example, Implementing the Home Page - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"React is a library widely used for building dynamic user interfaces. In this course, we will explore the basic concepts of React by creating a diary app. Along the way, we will also implement the Home page. The Home page will be the main screen where users can access the diary and write new entries. &hellip; \ub354 \ubcf4\uae30 &quot;React Course: Diary App Example, Implementing the Home Page&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32911\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:12:25+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:21:30+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/32911\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32911\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"React Course: Diary App Example, Implementing the Home Page\",\"datePublished\":\"2024-11-01T09:12:25+00:00\",\"dateModified\":\"2024-11-01T11:21:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32911\/\"},\"wordCount\":482,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"React basics course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32911\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32911\/\",\"name\":\"React Course: Diary App Example, Implementing the Home Page - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:12:25+00:00\",\"dateModified\":\"2024-11-01T11:21:30+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32911\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32911\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32911\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React Course: Diary App Example, Implementing the Home Page\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"React Course: Diary App Example, Implementing the Home Page - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","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:\/\/atmokpo.com\/w\/32911\/","og_locale":"ko_KR","og_type":"article","og_title":"React Course: Diary App Example, Implementing the Home Page - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"React is a library widely used for building dynamic user interfaces. In this course, we will explore the basic concepts of React by creating a diary app. Along the way, we will also implement the Home page. The Home page will be the main screen where users can access the diary and write new entries. &hellip; \ub354 \ubcf4\uae30 \"React Course: Diary App Example, Implementing the Home Page\"","og_url":"https:\/\/atmokpo.com\/w\/32911\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:12:25+00:00","article_modified_time":"2024-11-01T11:21:30+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/32911\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32911\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"React Course: Diary App Example, Implementing the Home Page","datePublished":"2024-11-01T09:12:25+00:00","dateModified":"2024-11-01T11:21:30+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32911\/"},"wordCount":482,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["React basics course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32911\/","url":"https:\/\/atmokpo.com\/w\/32911\/","name":"React Course: Diary App Example, Implementing the Home Page - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:12:25+00:00","dateModified":"2024-11-01T11:21:30+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32911\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32911\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32911\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"React Course: Diary App Example, Implementing the Home Page"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=32911"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32911\/revisions"}],"predecessor-version":[{"id":32912,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32911\/revisions\/32912"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}