<?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: Twinly | Software Engineering</title>
    <description>The latest articles on DEV Community by Twinly | Software Engineering (@twinly_dev).</description>
    <link>https://dev.to/twinly_dev</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4272439%2Fe463e0c2-ebcd-4070-82d0-940ef639dfdf.png</url>
      <title>DEV Community: Twinly | Software Engineering</title>
      <link>https://dev.to/twinly_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/twinly_dev"/>
    <language>en</language>
    <item>
      <title>Deleting a React view can be better than simplifying its state</title>
      <dc:creator>Twinly | Software Engineering</dc:creator>
      <pubDate>Sun, 29 Nov 2026 14:27:55 +0000</pubDate>
      <link>https://dev.to/twinly_dev/deleting-a-react-view-can-be-better-than-simplifying-its-state-3a94</link>
      <guid>https://dev.to/twinly_dev/deleting-a-react-view-can-be-better-than-simplifying-its-state-3a94</guid>
      <description>&lt;p&gt;A date-range switch looks like a harmless addition to a React component. In practice, it can introduce a second navigation model that has to stay in sync with the first.&lt;/p&gt;

&lt;p&gt;This happened in &lt;a href="https://twinly-prod.web.app/?lang=en" rel="noopener noreferrer"&gt;Twinly&lt;/a&gt;, a React and TypeScript baby tracker designed for twins. Its home screen already provides a daily summary. A separate timeline temporarily offered both daily and weekly views.&lt;/p&gt;

&lt;p&gt;The weekly timeline answers a different question: how did feeding, sleep and other care events change across several days? The daily view, meanwhile, overlapped with the home screen.&lt;/p&gt;

&lt;p&gt;The interesting part of this change was not building another component. It was removing one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The cost of a second navigation model
&lt;/h2&gt;

&lt;p&gt;The previous timeline kept three pieces of navigation state: a display mode, the selected day and the start of the selected week.&lt;/p&gt;

&lt;p&gt;A simplified excerpt of the old state declarations:&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;weekStart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setWeekStart&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;initialWeekStart&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="n"&gt;displayMode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setDisplayMode&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="n"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="s2"&gt;"day"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s2"&gt;"week"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"day"&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="n"&gt;dayDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setDayDate&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="nf"&gt;useState&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${initialDate}T00:00:00`&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Moving to another day updated both the selected date and the start of its week. Switching to weekly mode also calculated the corresponding week start. An effect reset the selected day and week when the initial date changed.&lt;/p&gt;

&lt;p&gt;None of these operations is particularly difficult. Together, however, they create more paths through the component. A change to date navigation now needs to account for two modes, their transitions and their reset behavior.&lt;/p&gt;

&lt;p&gt;The extra button came with extra luggage.&lt;/p&gt;

&lt;h2&gt;
  
  
  First ask whether both views are necessary
&lt;/h2&gt;

&lt;p&gt;React's documentation recommends avoiding redundant state when it can be calculated from other state. That is a useful starting point, but it does not tell us whether a product needs both modes in the first place.&lt;/p&gt;

&lt;p&gt;The design decision here was to keep today's summary on the home screen and restore the timeline to a weekly-only view. With that decision, the component no longer needed to maintain a selected day or display mode.&lt;/p&gt;

&lt;p&gt;The surviving date-navigation state was simply:&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;weekStart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setWeekStart&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;initialWeekStart&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;useEffect&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;setWeekStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;initialWeekStart&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="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;initialWeekStart&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These excerpts focus on date navigation; the actual component retains other state, such as the selected event.&lt;/p&gt;

&lt;p&gt;This is not a recommendation to delete every view that shares data with another screen. A daily view might be essential in a product where users inspect individual days in detail. Here, the existing daily summary made the extra timeline mode redundant for the intended workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Remove the implementation, not just its entry point
&lt;/h2&gt;

&lt;p&gt;The change also deleted the unused daily timeline component and its dedicated CSS, rather than hiding the toggle and leaving the old rendering path behind.&lt;/p&gt;

&lt;p&gt;The existing weekly navigation, event markers, tap-to-edit behavior and home-screen daily summary were preserved. The backend, persistence logic and data model did not need to change.&lt;/p&gt;

&lt;p&gt;The pull request records successful TypeScript checking, a build and deployment to the development Firebase Hosting environment. It was subsequently merged. These checks establish that the implementation passed those recorded development steps; they do not establish that users became faster at completing tasks. That would require separate usability evidence.&lt;/p&gt;

&lt;h2&gt;
  
  
  A useful review question
&lt;/h2&gt;

&lt;p&gt;Before adding state for a new display mode, identify the distinct user question that mode answers. If another surface already answers it, consider improving that surface instead.&lt;/p&gt;

&lt;p&gt;When removing a mode, check the corresponding state, effects, conditional rendering, styles and interaction paths. Preserve the data and behaviors that remain useful.&lt;/p&gt;

&lt;p&gt;React's guidance on &lt;a href="https://react.dev/learn/choosing-the-state-structure" rel="noopener noreferrer"&gt;choosing the state structure&lt;/a&gt; is a helpful companion to this approach. It addresses implementation complexity, while the product decision determines which complexity is worth keeping.&lt;/p&gt;

&lt;p&gt;A smaller state machine is a nice result. A screen that asks fewer unnecessary questions of its users is the actual goal.&lt;/p&gt;

&lt;p&gt;Disclosure: This article was generated by AI from verified Twinly development records.&lt;/p&gt;

</description>
      <category>react</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>ux</category>
    </item>
  </channel>
</rss>
