{"id":32923,"date":"2024-11-01T09:12:30","date_gmt":"2024-11-01T09:12:30","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32923"},"modified":"2024-11-01T11:21:27","modified_gmt":"2024-11-01T11:21:27","slug":"react-course-diary-app-example-page-routing-with-react-router","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32923\/","title":{"rendered":"React Course: Diary App Example, Page Routing with React Router"},"content":{"rendered":"<p><body><\/p>\n<p>In this course, we will explain step by step how to create a simple diary web application using React. This application allows users to write, edit, and delete diaries. Additionally, we will cover how to implement routing to various pages using React Router. This course will be explained in detail so that beginners can easily follow along.<\/p>\n<h2>Table of Contents<\/h2>\n<ol>\n<li><a href=\"#intro\">1. Project Introduction<\/a><\/li>\n<li><a href=\"#setup\">2. Setting Up the Development Environment<\/a><\/li>\n<li><a href=\"#create-app\">3. Creating a React App<\/a><\/li>\n<li><a href=\"#add-router\">4. Adding React Router<\/a><\/li>\n<li><a href=\"#build-components\">5. Building Components<\/a><\/li>\n<li><a href=\"#state-management\">6. State Management<\/a><\/li>\n<li><a href=\"#test\">7. Testing and Debugging<\/a><\/li>\n<li><a href=\"#deploy\">8. Deploying<\/a><\/li>\n<li><a href=\"#conclusion\">9. Conclusion<\/a><\/li>\n<\/ol>\n<h2 id=\"intro\">1. Project Introduction<\/h2>\n<p>The diary app provides users with a space to write personal diaries. Users can create new diaries, view previously written diaries in a list, and edit or delete them if necessary. In this process, we will learn the basic concepts of React and how to use React Router.<\/p>\n<h2 id=\"setup\">2. Setting Up the Development Environment<\/h2>\n<p>To use React, you must first install Node.js and npm (Node Package Manager). Once you have installed Node.js and npm, you can easily create and manage React applications. Please download and install it from the official website.<\/p>\n<h3>Installing Node.js<\/h3>\n<p>Download and install the installation file suitable for your operating system from the <a href=\"https:\/\/nodejs.org\/\">official Node.js website<\/a>.<\/p>\n<h3>Updating the Package Manager<\/h3>\n<p>After installation, check if npm is up to date and update it if necessary. Enter the following command in the console:<\/p>\n<pre><code>npm install -g npm@latest<\/code><\/pre>\n<h2 id=\"create-app\">3. Creating a React App<\/h2>\n<p>Now let&#8217;s create a new React project using create-react-app. Enter the following command in the console:<\/p>\n<pre><code>npx create-react-app my-diary-app<\/code><\/pre>\n<p>Navigate to the project folder:<\/p>\n<pre><code>cd my-diary-app<\/code><\/pre>\n<p>Then, start the development server:<\/p>\n<pre><code>npm start<\/code><\/pre>\n<p>Navigate to <strong>http:\/\/localhost:3000<\/strong> in your browser to check if the default React page is displayed.<\/p>\n<h2 id=\"add-router\">4. Adding React Router<\/h2>\n<p>Now, let&#8217;s install React Router to add routing functionality to the application. Enter the following command to install React Router:<\/p>\n<pre><code>npm install react-router-dom<\/code><\/pre>\n<p>Open the app\/src\/index.js file and set up the router:<\/p>\n<pre><code>import { BrowserRouter as Router } from 'react-router-dom';<\/code><\/pre>\n<p>Wrap the app with the Router:<\/p>\n<pre><code>\n    ReactDOM.render(\n      <Router>\n        <App><\/App>\n      <\/Router>,\n      document.getElementById('root')\n    );<\/code><\/pre>\n<h2 id=\"build-components\">5. Building Components<\/h2>\n<p>Now, let&#8217;s create components to set up the pages for routing. We will create a diary list page and a diary creation page.<\/p>\n<h3>Diary List Component<\/h3>\n<p>Create app\/src\/components\/DiaryList.js and enter the following code:<\/p>\n<pre><code>\n    import React from 'react';\n\n    const DiaryList = () => {\n        return (\n            <div>\n                <h2>Diary List<\/h2>\n                <ul>\n                    <li>Title: Day One, Content: I felt good today.<\/li>\n                    <li>Title: Day Two, Content: The weather was nice.<\/li>\n                    {\/* You can add more diaries *\/}\n                <\/ul>\n            <\/div>\n        );\n    };\n\n    export default DiaryList;<\/code><\/pre>\n<h3>Diary Creation Component<\/h3>\n<p>Create app\/src\/components\/CreateDiary.js and enter the following code:<\/p>\n<pre><code>\n    import React from 'react';\n\n    const CreateDiary = () => {\n        return (\n            <div>\n                <h2>Create Diary<\/h2>\n                <form>\n                    <label>Title: <\/label>\n                    <input type=\"text\"\/>\n                    <label>Content: <\/label>\n                    <textarea><\/textarea>\n                    <button type=\"submit\">Save<\/button>\n                <\/form>\n            <\/div>\n        );\n    };\n\n    export default CreateDiary;<\/code><\/pre>\n<h2 id=\"state-management\">6. State Management<\/h2>\n<p>To manage the diaries written in the diary app, you need to use React&#8217;s useState hook. Open the App.js file and set up the state.<\/p>\n<pre><code>\n    import React, { useState } from 'react';\n    import DiaryList from '.\/components\/DiaryList';\n    import CreateDiary from '.\/components\/CreateDiary';\n\n    const App = () => {\n        const [diaries, setDiaries] = useState([]);\n\n        \/\/ Add diary entry functions and more example code here\n            \n        return (\n            <div>\n                <h1>My Diary<\/h1>\n                {\/* Add routing settings *\/}\n            <\/div>\n        );\n    };\n\n    export default App;<\/code><\/pre>\n<h2 id=\"test\">7. Testing and Debugging<\/h2>\n<p>Test each component and functionality of the application to ensure they work properly. If the desired results do not appear, use console.log for debugging. For instance, check if the state updates as expected.<\/p>\n<h2 id=\"deploy\">8. Deploying<\/h2>\n<p>To deploy, you first need to build the app. You can do this by entering the following command in the console:<\/p>\n<pre><code>npm run build<\/code><\/pre>\n<p>You can then deploy the generated build folder to a server. Various deployment services such as Firebase, Vercel, and Netlify can be used.<\/p>\n<h2 id=\"conclusion\">9. Conclusion<\/h2>\n<p>In this course, we learned how to create a simple diary application using React and how to implement routing to multiple pages using React Router. Through practical exercises, we were able to grasp the basic principles of React, state management, and routing. We hope you gain more experience by implementing additional features and deploying your application.<\/p>\n<p>Thank you!<\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this course, we will explain step by step how to create a simple diary web application using React. This application allows users to write, edit, and delete diaries. Additionally, we will cover how to implement routing to various pages using React Router. This course will be explained in detail so that beginners can easily &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32923\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;React Course: Diary App Example, Page Routing with React Router&#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-32923","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, Page Routing with React Router - \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\/32923\/\" \/>\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, Page Routing with React Router - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"In this course, we will explain step by step how to create a simple diary web application using React. This application allows users to write, edit, and delete diaries. Additionally, we will cover how to implement routing to various pages using React Router. This course will be explained in detail so that beginners can easily &hellip; \ub354 \ubcf4\uae30 &quot;React Course: Diary App Example, Page Routing with React Router&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32923\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:12:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:21:27+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\/32923\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32923\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"React Course: Diary App Example, Page Routing with React Router\",\"datePublished\":\"2024-11-01T09:12:30+00:00\",\"dateModified\":\"2024-11-01T11:21:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32923\/\"},\"wordCount\":545,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"React basics course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32923\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32923\/\",\"name\":\"React Course: Diary App Example, Page Routing with React Router - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:12:30+00:00\",\"dateModified\":\"2024-11-01T11:21:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32923\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32923\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32923\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React Course: Diary App Example, Page Routing with React Router\"}]},{\"@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, Page Routing with React Router - \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\/32923\/","og_locale":"ko_KR","og_type":"article","og_title":"React Course: Diary App Example, Page Routing with React Router - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"In this course, we will explain step by step how to create a simple diary web application using React. This application allows users to write, edit, and delete diaries. Additionally, we will cover how to implement routing to various pages using React Router. This course will be explained in detail so that beginners can easily &hellip; \ub354 \ubcf4\uae30 \"React Course: Diary App Example, Page Routing with React Router\"","og_url":"https:\/\/atmokpo.com\/w\/32923\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:12:30+00:00","article_modified_time":"2024-11-01T11:21:27+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\/32923\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32923\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"React Course: Diary App Example, Page Routing with React Router","datePublished":"2024-11-01T09:12:30+00:00","dateModified":"2024-11-01T11:21:27+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32923\/"},"wordCount":545,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["React basics course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32923\/","url":"https:\/\/atmokpo.com\/w\/32923\/","name":"React Course: Diary App Example, Page Routing with React Router - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:12:30+00:00","dateModified":"2024-11-01T11:21:27+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/32923\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32923\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32923\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"React Course: Diary App Example, Page Routing with React Router"}]},{"@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\/32923","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=32923"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32923\/revisions"}],"predecessor-version":[{"id":32924,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32923\/revisions\/32924"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}