<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Bony_Chops</title>
    <description>The latest articles on DEV Community by Bony_Chops (@bonychops).</description>
    <link>https://dev.to/bonychops</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F901160%2F3c4abad2-b24c-46c1-bd15-2d9e923a215d.png</url>
      <title>DEV Community: Bony_Chops</title>
      <link>https://dev.to/bonychops</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bonychops"/>
    <language>en</language>
    <item>
      <title>🔄 Displaying React Components in Reverse Order</title>
      <dc:creator>Bony_Chops</dc:creator>
      <pubDate>Sat, 14 Oct 2023 08:02:38 +0000</pubDate>
      <link>https://dev.to/bonychops/displaying-react-components-in-reverse-order-354g</link>
      <guid>https://dev.to/bonychops/displaying-react-components-in-reverse-order-354g</guid>
      <description>&lt;h2&gt;
  
  
  ⚠Disclaimer
&lt;/h2&gt;

&lt;p&gt;This article has been translated using ChatGPT by the author; as such, some parts may not be accurately represented or contextually appropriate. For the original content, please refer to the link provided below.&lt;br&gt;
&lt;a href="https://zenn.dev/bony_chops/articles/34969d261d7553"&gt;https://zenn.dev/bony_chops/articles/34969d261d7553&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Preface
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://bonychops.com"&gt;https://bonychops.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While creating my own portfolio, I realized that my professional experiences were listed in ascending chronological order.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5PuXViQ4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28rtc323kluqjlew7km8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5PuXViQ4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/28rtc323kluqjlew7km8.png" alt="A timeline graphic displaying significant events or milestones. At the top, there's a &amp;quot;Show All&amp;quot; toggle and a reference link to &amp;quot;Wantedly&amp;quot;. Entries are denoted with dates and ages: 2002.07.30 at 0 years old: A symbol (possibly representing birth) with the text &amp;quot;誕生&amp;quot; (meaning &amp;quot;Birth&amp;quot;), 2018.04 at 16 years old: A symbol with Japanese characters indicating a school or educational milestone, 2020.10.7 - 10.28 at 18 years old: Details about a project titled &amp;quot;WebxIoT メイカーズチャレンジ 2020-21 in 信州 長野&amp;quot;, with technologies used such as JavaScript, MaterializeCSS, and GitHub Pages, 2022.11.28 - 12.17 at 20 years old: An event or competition titled &amp;quot;Hack U KOSEN 2022&amp;quot; followed by some Japanese characters, Each entry has corresponding icons indicating the type of event or the technologies used. The background is white, and the timeline is indicated with a central dotted line." width="800" height="1017"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, looking at Wantedly, I noticed that the experiences are listed in descending order. I want my format to align with this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vJY2Bas_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hljeppq1t5dxhj8cte26.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJY2Bas_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hljeppq1t5dxhj8cte26.png" alt="A profile section featuring a male individual's photo on the left. The section is titled &amp;quot;この先やってみたいこと&amp;quot; (What I'd like to do in the future). Below the title: A brief description: The individual expresses interest in learning and working on complex systems such as large-scale cloud platforms, contributing to open-source projects, and improving system reliability. Following this description, there's a vertical timeline: From July 2023 to October 2023: An entry labeled &amp;quot;ピクシブ株式会社&amp;quot; (Pixiv Corporation) with a duration of 4 months, accompanied by the text &amp;quot;フラットワーク研究部（インターン）&amp;quot; indicating an internship in the Flatwork Research Department, Starting from January 2020: An entry titled &amp;quot;アドリエももも&amp;quot; (Atelier Momomo) with a duration of 3 years, accompanied by the text &amp;quot;システムメンテナ - 独立&amp;quot;, which indicates the role of independent system maintainer, The background is white, with events and descriptions connected by a dotted line." width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But now, reversing the order of this many components would be a huge task...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bUWhtSvo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zm72balmitsi1o3i5z67.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bUWhtSvo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zm72balmitsi1o3i5z67.png" alt="A screenshot of a VSCode preview thumbnail displaying multiple lines of code. The code consists of various color-coded syntax elements, suggesting a structured program or script. The specific content of the code is not detailed, but the image conveys a dense coding environment." width="278" height="980"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Strategy
&lt;/h2&gt;

&lt;p&gt;For instance, we aim to reverse the order of the following components.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;a&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;b&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;c&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RVLfUax6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gyoelchax89l4u7ox9yo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RVLfUax6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gyoelchax89l4u7ox9yo.png" alt="a, b, c" width="402" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;↑I want the order to be c, b, a.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a &lt;code&gt;&amp;lt;ReverseComponent&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Enclose the target components with it&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Creating the &lt;code&gt;ReverseComponent&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;First, we will create the ReverseComponent as follows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;ReverseComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;children&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ReactNode&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;reverse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reverse&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When multiple components are passed to children, they are passed as an Array. So, if it is an Array, we use &lt;code&gt;.reverse()&lt;/code&gt; to reverse the order.&lt;/p&gt;

&lt;h3&gt;
  
  
  About &lt;code&gt;.slice&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Since &lt;code&gt;children&lt;/code&gt; are passed as readOnly, we cannot use the destructive &lt;code&gt;.reverse()&lt;/code&gt;. So, we use &lt;code&gt;.slice()&lt;/code&gt; to make a shallow copy and use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enclosing the Components
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt; &amp;lt;div&amp;gt;
&lt;span class="gi"&gt;+   &amp;lt;ReverseComponent&amp;gt;
&lt;/span&gt;        &amp;lt;p&amp;gt;a&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;b&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;c&amp;lt;/p&amp;gt;
&lt;span class="gi"&gt;+   &amp;lt;/ReverseComponent&amp;gt;
&lt;/span&gt; &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OdTa4eBi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0myc811t2ncnj6r8ojmd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OdTa4eBi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0myc811t2ncnj6r8ojmd.png" alt="c, b, a" width="420" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tada 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  Making it Switchable
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt; import React from "react";

 export default function ReverseComponent(props: {
   children: React.ReactNode;
&lt;span class="gi"&gt;+  reverse?: boolean;
&lt;/span&gt; }) {
   const { children } = props;
&lt;span class="gi"&gt;+  const reverse = props.reverse ?? true;
&lt;/span&gt;
   if (Array.isArray(children)) {
&lt;span class="gd"&gt;-    return children.slice().reverse();
&lt;/span&gt;&lt;span class="gi"&gt;+    return reverse ? children.slice().reverse() : children;
&lt;/span&gt;   }
   return children;
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt; &amp;lt;div&amp;gt;
&lt;span class="gd"&gt;-   &amp;lt;ReverseComponent&amp;gt;
&lt;/span&gt;&lt;span class="gi"&gt;+   &amp;lt;ReverseComponent reverse={false}&amp;gt;
&lt;/span&gt;        &amp;lt;p&amp;gt;a&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;b&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;c&amp;lt;/p&amp;gt;
    &amp;lt;/ReverseComponent&amp;gt;
 &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TaElxCZx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqkhwfkznujvv56wwx0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TaElxCZx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fqkhwfkznujvv56wwx0q.png" alt="a, b, c" width="402" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you can dynamically switch between ascending and descending order.&lt;/p&gt;

&lt;h2&gt;
  
  
  Applying to the Portfolio
&lt;/h2&gt;

&lt;p&gt;It was extremely easy to reverse the order by just creating one component. Also, I made a button to reverse the order as a bonus.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rTEIiEAW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5i1vavp2djc0nvd5m70g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rTEIiEAW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5i1vavp2djc0nvd5m70g.png" alt="A section titled &amp;quot;Timeline&amp;quot; displaying user interface controls. There are two toggle switches labeled &amp;quot;Show All&amp;quot; (currently activated) and &amp;quot;Reverse&amp;quot;. Below the controls, there's a reference link to &amp;quot;Wantedly&amp;quot;. Further down, there's a timeline entry for the year 2023 indicating an age of 21 years old with an associated symbol and question marks (???), suggesting an unknown or undisclosed event. The background is white with a minimalistic design." width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/BonyChops/portfolio-v3/pull/11"&gt;https://github.com/BonyChops/portfolio-v3/pull/11&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Verifying My OpenPGP Key</title>
      <dc:creator>Bony_Chops</dc:creator>
      <pubDate>Fri, 03 Feb 2023 01:53:10 +0000</pubDate>
      <link>https://dev.to/bonychops/verifying-my-openpgp-key-29jm</link>
      <guid>https://dev.to/bonychops/verifying-my-openpgp-key-29jm</guid>
      <description>&lt;p&gt;This is an OpenPGP proof that connects &lt;a href="https://keyoxide.org/7B03D8A1D6B3D7A5129FB36C457BF5D69ECE0883"&gt;my OpenPGP key&lt;/a&gt; to &lt;a href="https://dev.to/bonychops"&gt;this dev.to account&lt;/a&gt;. For details check out &lt;a href="https://keyoxide.org/guides/openpgp-proofs"&gt;https://keyoxide.org/guides/openpgp-proofs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[Verifying my OpenPGP key: openpgp4fpr:7B03D8A1D6B3D7A5129FB36C457BF5D69ECE0883]&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
