{"id":32915,"date":"2024-11-01T09:12:27","date_gmt":"2024-11-01T09:12:27","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32915"},"modified":"2024-11-01T11:21:29","modified_gmt":"2024-11-01T11:21:29","slug":"react-course-diary-app-example","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32915\/","title":{"rendered":"React Course: Diary App Example"},"content":{"rendered":"<p><body><\/p>\n<div class=\"container\">\n<h2>Setting Common Styles<\/h2>\n<p>Hello! In this React tutorial, we will learn about React and how to set common styles through a diary app example. React is a component-based library that is very useful for building user interfaces. The diary app we will develop in this tutorial will be an application where users can record their thoughts and feelings.<\/p>\n<h2>Project Setup<\/h2>\n<p>First, we will create a new React project. For this, we will use <code>create-react-app<\/code>. Run the command below to set up the project:<\/p>\n<pre>\n    npx create-react-app diary-app\n    cd diary-app\n    npm start\n    <\/pre>\n<h2>Setting Common Styles<\/h2>\n<p>To ensure visual consistency in the diary app, we need to set common styles. Generally, styles can be set through a CSS file, but in React, we can use methods such as <code>styled-components<\/code> or <code>CSS Modules<\/code>. Here, we will simply use the <code>App.css<\/code> file to set up styles.<\/p>\n<h3>Creating Basic Styles<\/h3>\n<p>First, open the <code>src\/App.css<\/code> file and add the basic styles as follows:<\/p>\n<pre>\n    body {\n        background-color: #f0f4f8;\n        font-family: 'Arial', sans-serif;\n        margin: 0;\n        padding: 0;\n    }\n\n    h1 {\n        color: #333;\n        text-align: center;\n    }\n\n    .diary-entry {\n        border: 1px solid #ddd;\n        border-radius: 4px;\n        padding: 15px;\n        margin: 10px 0;\n        background: #fff;\n        box-shadow: 1px 1px 5px rgba(0,0,0,0.1);\n    }\n\n    .entry-title {\n        font-size: 1.5em;\n        color: #007acc;\n    }\n\n    .entry-date {\n        color: #888;\n        font-size: 0.9em;\n    }\n\n    .entry-content {\n        margin-top: 10px;\n        font-size: 1.1em;\n    }\n    <\/pre>\n<h3>Creating a Diary Component<\/h3>\n<p>We will create a new component to display diary entries. Create a file named <code>src\/DiaryEntry.js<\/code> and write as follows:<\/p>\n<pre>\n\/\/ src\/DiaryEntry.js\nimport React from 'react';\nimport '.\/App.css';\n\nconst DiaryEntry = ({ title, date, content }) =&gt; {\n    return (\n        <div classname=\"diary-entry\">\n            <h2 classname=\"entry-title\">{title}<\/h2>\n            <p classname=\"entry-date\">{date}<\/p>\n            <p classname=\"entry-content\">{content}<\/p>\n        <\/div>\n    );\n};\n\nexport default DiaryEntry;\n    <\/pre>\n<h3>Final Structure of the Diary App<\/h3>\n<p>Now, let&#8217;s open the <code>src\/App.js<\/code> file and write as follows:<\/p>\n<pre>\n\/\/ src\/App.js\nimport React from 'react';\nimport DiaryEntry from '.\/DiaryEntry';\nimport '.\/App.css';\n\nconst App = () =&gt; {\n    const diaryEntries = [\n        { title: 'First Diary', date: '2023-10-01', content: 'Today was really a happy day!' },\n        { title: 'Second Diary', date: '2023-10-02', content: 'It\\'s a rainy day. I feel a little down.' },\n        { title: 'Third Diary', date: '2023-10-03', content: 'I looked at the sky while reading a good book.' },\n    ];\n\n    return (\n        <div>\n            <h1>My Diary<\/h1>\n            {diaryEntries.map((entry, index) =&gt; (\n                <diaryentry content=\"{entry.content}\" date=\"{entry.date}\" key=\"{index}\" title=\"{entry.title}\"><\/diaryentry>\n            ))}\n        <\/div>\n    );\n};\n\nexport default App;\n    <\/pre>\n<h2>State Management and Styling<\/h2>\n<p>To enhance the styles of the diary app, various styles can be applied along with state management. For example, implementing features to add and delete diary entries can improve user experience.<\/p>\n<h3>Using State Management Libraries<\/h3>\n<p>We will use the <code>useState<\/code> and <code>useEffect<\/code> hooks for state management in React. Add the code below to <code>src\/App.js<\/code> to implement the feature for adding diary entries:<\/p>\n<pre>\nimport React, { useState } from 'react';\n\/\/ import DiaryEntry from '.\/DiaryEntry';\n\/\/ import '.\/App.css';\n\nconst App = () =&gt; {\n    const [entries, setEntries] = useState([\n        { title: 'First Diary', date: '2023-10-01', content: 'Today was really a happy day!' },\n        { title: 'Second Diary', date: '2023-10-02', content: 'It\\'s a rainy day. I feel a little down.' },\n    ]);\n\n    const [title, setTitle] = useState('');\n    const [content, setContent] = useState('');\n\n    const addEntry = () =&gt; {\n        const newEntry = {\n            title,\n            date: new Date().toLocaleDateString(),\n            content,\n        };\n        setEntries([...entries, newEntry]);\n        setTitle('');\n        setContent('');\n    };\n\n    return (\n        <div>\n            <h1>My Diary<\/h1>\n            <input ==\"\" onchange=\"{(e)\" placeholder=\"Enter title\" type=\"text\" value=\"{title}\"\/> setTitle(e.target.value)}\n            \/&gt;\n            <textarea ==\"\" onchange=\"{(e)\" placeholder=\"Enter content\" value=\"{content}\"> setContent(e.target.value)}\n            \/&gt;\n            <button onclick=\"{addEntry}\">Add Diary<\/button>\n            {entries.map((entry, index) =&gt; (\n                <diaryentry content=\"{entry.content}\" date=\"{entry.date}\" key=\"{index}\" title=\"{entry.title}\"><\/diaryentry>\n            ))}\n        <\/textarea><\/div>\n    );\n};\n\nexport default App;\n    <\/pre>\n<h2>Conclusion<\/h2>\n<p>Now we have learned how to set up a diary app using React and how to set common styles. Through these basic elements, we have established a foundation necessary to develop more complex applications. Upcoming topics will include styling libraries, data fetching, and more complex state management patterns. I hope you continue to learn and practice React to become a better developer!<\/p>\n<\/div>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting Common Styles Hello! In this React tutorial, we will learn about React and how to set common styles through a diary app example. React is a component-based library that is very useful for building user interfaces. The diary app we will develop in this tutorial will be an application where users can record their &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32915\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;React Course: Diary App Example&#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-32915","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 - \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\/32915\/\" \/>\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 - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Setting Common Styles Hello! In this React tutorial, we will learn about React and how to set common styles through a diary app example. React is a component-based library that is very useful for building user interfaces. The diary app we will develop in this tutorial will be an application where users can record their &hellip; \ub354 \ubcf4\uae30 &quot;React Course: Diary App Example&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32915\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:12:27+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:21:29+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=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/32915\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32915\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"React Course: Diary App Example\",\"datePublished\":\"2024-11-01T09:12:27+00:00\",\"dateModified\":\"2024-11-01T11:21:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32915\/\"},\"wordCount\":312,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"React basics course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32915\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32915\/\",\"name\":\"React Course: Diary App Example - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:12:27+00:00\",\"dateModified\":\"2024-11-01T11:21:29+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32915\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32915\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32915\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React Course: Diary App Example\"}]},{\"@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 - \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\/32915\/","og_locale":"ko_KR","og_type":"article","og_title":"React Course: Diary App Example - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Setting Common Styles Hello! In this React tutorial, we will learn about React and how to set common styles through a diary app example. React is a component-based library that is very useful for building user interfaces. The diary app we will develop in this tutorial will be an application where users can record their &hellip; \ub354 \ubcf4\uae30 \"React Course: Diary App Example\"","og_url":"https:\/\/atmokpo.com\/w\/32915\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:12:27+00:00","article_modified_time":"2024-11-01T11:21:29+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":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/32915\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32915\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"React Course: Diary App Example","datePublished":"2024-11-01T09:12:27+00:00","dateModified":"2024-11-01T11:21:29+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32915\/"},"wordCount":312,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["React basics course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32915\/","url":"https:\/\/atmokpo.com\/w\/32915\/","name":"React Course: Diary App Example - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:12:27+00:00","dateModified":"2024-11-01T11:21:29+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32915\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32915\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32915\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"React Course: Diary App Example"}]},{"@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\/32915","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=32915"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32915\/revisions"}],"predecessor-version":[{"id":32916,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32915\/revisions\/32916"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}