{"id":32917,"date":"2024-11-01T09:12:27","date_gmt":"2024-11-01T09:12:27","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=32917"},"modified":"2024-11-01T11:21:29","modified_gmt":"2024-11-01T11:21:29","slug":"react-course-implementing-button-and-header-components-for-a-diary-app","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/32917\/","title":{"rendered":"React Course: Implementing Button and Header Components for a Diary App"},"content":{"rendered":"<p><body><\/p>\n<p>\n        This course provides a step-by-step explanation of how to implement common components like<br \/>\n        <strong>Button<\/strong> and <strong>Header<\/strong> for a diary application using React.<br \/>\n        The diary app is a web application that allows users to write and save their diaries,<br \/>\n        and it is recommended to use React to make the basic UI components familiar.\n    <\/p>\n<h2>What is React?<\/h2>\n<p>\n        React is a JavaScript library for building user interfaces.<br \/>\n        When building the UI of web applications, it maximizes reusability and efficiency through a component-based structure.<br \/>\n        React allows for easy management and updating of dynamic UIs using state and props.\n    <\/p>\n<h2>What are Common Components?<\/h2>\n<p>\n        Common components refer to UI elements that can be reused in multiple places.<br \/>\n        In the diary application, elements such as <code>Button<\/code> and <code>Header<\/code> are frequently used,<br \/>\n        so separating them into components can reduce code duplication and make maintenance easier.\n    <\/p>\n<h2>Project Setup<\/h2>\n<p>\n        Before starting the project, you need to set up the React environment.<br \/>\n        To start a new React application, enter the following command to create a React app:\n    <\/p>\n<pre><code>npx create-react-app diary-app<\/code><\/pre>\n<p>\n        Then, navigate to the created directory and run the project:\n    <\/p>\n<pre><code>cd diary-app\nnpm start<\/code><\/pre>\n<h2>Implementing Common Components<\/h2>\n<h3>1. Button Component<\/h3>\n<p>\n<code>Button<\/code> component is responsible for creating a clickable button.<br \/>\n        This component allows for the easy addition of various button styles and functionalities.<br \/>\n        Let&#8217;s create the <code>Button<\/code> component with the code below.\n    <\/p>\n<pre><code>\nimport React from 'react';\nimport '.\/Button.css'; \/\/ CSS file for styling\n\nconst Button = ({ onClick, children, className }) =&gt; {\n    return (\n        <button className={className} onClick={onClick}>\n            {children}\n        <\/button>\n    );\n};\n\nexport default Button;\n    <\/code><\/pre>\n<p>\n        In the above code, the <strong>Button<\/strong> component receives three properties:\n    <\/p>\n<ul>\n<li><strong>onClick<\/strong>: The function to be called when the button is clicked<\/li>\n<li><strong>children<\/strong>: The content to be placed inside the button<\/li>\n<li><strong>className<\/strong>: A property that allows the application of additional CSS classes<\/li>\n<\/ul>\n<p>\n        Now, let&#8217;s create a <code>Button.css<\/code> file to define the styles.<br \/>\n        We will set the basic style of the button as follows.\n    <\/p>\n<pre><code>\n.button {\n    padding: 10px 20px;\n    font-size: 16px;\n    color: white;\n    background-color: #007bff;\n    border: none;\n    border-radius: 4px;\n    cursor: pointer;\n    transition: background-color 0.3s;\n}\n\n.button:hover {\n    background-color: #0056b3;\n}\n    <\/code><\/pre>\n<h3>2. Header Component<\/h3>\n<p>\n<code>Header<\/code> component contains the title and other elements displayed at the top of the application.<br \/>\n        Let&#8217;s implement the <code>Header<\/code> component with the code below.\n    <\/p>\n<pre><code>\nimport React from 'react';\nimport '.\/Header.css';\n\nconst Header = () =&gt; {\n    return (\n        <header className=\"header\">\n            <h1>My Diary<\/h1>\n        <\/header>\n    );\n};\n\nexport default Header;\n    <\/code><\/pre>\n<p>\n        The above code creates a simple <strong>Header<\/strong> component that includes the title of the diary.<br \/>\n        Create a <code>Header.css<\/code> file and specify the styles as follows.\n    <\/p>\n<pre><code>\n.header {\n    padding: 20px;\n    background-color: #f8f9fa;\n    text-align: center;\n    border-bottom: 1px solid #dee2e6;\n}\n.header h1 {\n    margin: 0;\n    color: #333;\n}\n    <\/code><\/pre>\n<h2>Integrating into the App Component<\/h2>\n<p>\n        Now, let&#8217;s use the implemented <code>Button<\/code> and <code>Header<\/code> components in <code>App.js<\/code>.<br \/>\n        Modify <code>App.js<\/code> as below to integrate the two components.\n    <\/p>\n<pre><code>\nimport React from 'react';\nimport Header from '.\/Header';\nimport Button from '.\/Button';\n\nconst App = () =&gt; {\n    const handleButtonClick = () =&gt; {\n        alert('Button has been clicked!');\n    };\n\n    return (\n        <div>\n            <Header \/>\n            <main>\n                <h2>Write a Diary<\/h2>\n                <Button onClick={handleButtonClick}>Write a Diary<\/Button>\n            <\/main>\n        <\/div>\n    );\n};\n\nexport default App;\n    <\/code><\/pre>\n<h2>Conclusion<\/h2>\n<p>\n        In this course, we explored how to implement common components of the diary application,<br \/>\n        <strong>Button<\/strong> and <strong>Header<\/strong>, using React.<br \/>\n        By creating these common components, we can enhance code reusability and simplify maintenance.<br \/>\n        If you have gained a deeper understanding of the basics of React components, it will greatly help you in developing more complex applications in the future.\n    <\/p>\n<h2>Additional Learning Resources<\/h2>\n<p>\n        The official React documentation offers more information and examples about components.<br \/>\n        If you want to deepen your understanding of React, please refer to the links below.\n    <\/p>\n<ul>\n<li><a href=\"https:\/\/reactjs.org\/docs\/getting-started.html\" target=\"_blank\" rel=\"noopener\">Official React Documentation<\/a><\/li>\n<li><a href=\"https:\/\/reactjs.org\/docs\/components-and-props.html\" target=\"_blank\" rel=\"noopener\">Components and Props<\/a><\/li>\n<li><a href=\"https:\/\/reactjs.org\/docs\/state-and-lifecycle.html\" target=\"_blank\" rel=\"noopener\">State and Lifecycle<\/a><\/li>\n<\/ul>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This course provides a step-by-step explanation of how to implement common components like Button and Header for a diary application using React. The diary app is a web application that allows users to write and save their diaries, and it is recommended to use React to make the basic UI components familiar. What is React? &hellip; <a href=\"https:\/\/atmokpo.com\/w\/32917\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;React Course: Implementing Button and Header Components for a Diary App&#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-32917","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: Implementing Button and Header Components for a Diary App - \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\/32917\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"React Course: Implementing Button and Header Components for a Diary App - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"This course provides a step-by-step explanation of how to implement common components like Button and Header for a diary application using React. The diary app is a web application that allows users to write and save their diaries, and it is recommended to use React to make the basic UI components familiar. What is React? &hellip; \ub354 \ubcf4\uae30 &quot;React Course: Implementing Button and Header Components for a Diary App&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/32917\/\" \/>\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\/32917\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32917\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"React Course: Implementing Button and Header Components for a Diary App\",\"datePublished\":\"2024-11-01T09:12:27+00:00\",\"dateModified\":\"2024-11-01T11:21:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/32917\/\"},\"wordCount\":450,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"React basics course\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/32917\/\",\"url\":\"https:\/\/atmokpo.com\/w\/32917\/\",\"name\":\"React Course: Implementing Button and Header Components for a Diary App - \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\/32917\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/32917\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/32917\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"React Course: Implementing Button and Header Components for a Diary App\"}]},{\"@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: Implementing Button and Header Components for a Diary App - \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\/32917\/","og_locale":"ko_KR","og_type":"article","og_title":"React Course: Implementing Button and Header Components for a Diary App - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"This course provides a step-by-step explanation of how to implement common components like Button and Header for a diary application using React. The diary app is a web application that allows users to write and save their diaries, and it is recommended to use React to make the basic UI components familiar. What is React? &hellip; \ub354 \ubcf4\uae30 \"React Course: Implementing Button and Header Components for a Diary App\"","og_url":"https:\/\/atmokpo.com\/w\/32917\/","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\/32917\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/32917\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"React Course: Implementing Button and Header Components for a Diary App","datePublished":"2024-11-01T09:12:27+00:00","dateModified":"2024-11-01T11:21:29+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/32917\/"},"wordCount":450,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["React basics course"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/32917\/","url":"https:\/\/atmokpo.com\/w\/32917\/","name":"React Course: Implementing Button and Header Components for a Diary App - \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\/32917\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/32917\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/32917\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"React Course: Implementing Button and Header Components for a Diary App"}]},{"@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\/32917","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=32917"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32917\/revisions"}],"predecessor-version":[{"id":32918,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/32917\/revisions\/32918"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=32917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=32917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=32917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}