<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-dgsuki7nv" -->

---
title: Refactoring a Messy React Workflow: From One Giant Modal...
description: A deep, fictional case study walks through refactoring a single large React dialog component (a 'Catalog Setup Hub' handling product creation, file import, and...
canonical: https://daily.dev/posts/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-dgsuki7nv
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Refactoring a Messy React Workflow: From One Giant Modal to Independent Vertical Slices | daily.dev
og:description: A deep, fictional case study walks through refactoring a single large React dialog component (a 'Catalog Setup Hub' handling product creation, file import, and...
og:url: https://daily.dev/posts/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-dgsuki7nv
og:image: https://api.daily.dev/og/posts/dGsukI7NV.png
og:image:alt: Refactoring a Messy React Workflow: From One Giant Modal to Independent Vertical Slices
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Refactoring a Messy React Workflow: From One Giant Modal to Independent Vertical Slices

**[Medium](https://daily.dev/sources/medium_js)** · 15 min read · 0 upvotes · 0 comments

## Summary

A deep, fictional case study walks through refactoring a single large React dialog component (a 'Catalog Setup Hub' handling product creation, file import, and collection creation) into independent vertical slices. It covers defining a behavior contract before touching code, designing narrow operation-specific ports instead of one generic interface, using a dialog-scoped Zustand store composed from slice factories, using TanStack Query as orchestration rather than state ownership, modeling partial import failure and selective retry as first-class states, distinguishing committed success from host-callback rejection, enforcing architecture boundaries via ESLint's Node API, and proving equivalence between legacy and refactored implementations with a shared black-box conformance test suite. It closes with concrete decision rules for when this level of structure is (and isn't) worth the added complexity.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@srachel27/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-32265d6d7c8b>

## Questions this post answers

### How do you handle partial failure in a React import workflow with retries?

Partial failure should be modeled as durable state rather than a generic error. When a batch import partially succeeds, successful items are merged by client ID and kept committed, while failed items remain visible; retry submits only items whose status is not 'succeeded'. Completion fires only once all items succeed, preserving already-committed results across retries.

_Developers designing resilient import flows can find deeper architecture breakdowns like this on daily.dev._

### Should TanStack Query own form state and draft data in a React mutation workflow?

No, TanStack Query should orchestrate the asynchronous transition, not own the form draft or persisted per-item statuses. A dedicated state slice (for example, a Zustand store) holds the draft and results, while the mutation's lifecycle callbacks (onMutate, onSuccess, onError, onSettled) coordinate running state, host notification, and duplicate-submit locking.

_Engineers weighing state ownership boundaries with TanStack Query can track patterns like this via daily.dev._

### How do you prove a React component refactor preserves the same behavior as the original?

Run both the legacy and refactored components through one shared black-box conformance test suite that interacts only through accessible labels, roles, and visible statuses, never through internal hooks or DOM details. Combine this with static architecture tests, such as invoking ESLint's Node API to assert that boundary-violating imports between slices are reported.

_Teams validating behavior-preserving refactors can explore similar testing strategies on daily.dev._

## Similar posts on daily.dev

- [Do we need state management libraries anymore?](https://daily.dev/posts/do-we-need-state-management-libraries-anymore--hihonpucg) · Neciu Dan · 4 upvotes · 1 comments
- [Designers already think in React](https://daily.dev/posts/designers-already-think-in-react-rbce4lfse) · thoughbot · 6 upvotes · 1 comments
- [Breaking the Re-render Chain: Our Migration from Context to Zustand](https://daily.dev/posts/breaking-the-re-render-chain-our-migration-from-context-to-zustand-iens0uzws) · Trendyol Tech · 63 upvotes · 1 comments
- [How I Learned to Structure React Projects Around Change, Not Folders](https://daily.dev/posts/how-i-learned-to-structure-react-projects-around-change-not-folders-ccelaqkhn) · Medium · 121 upvotes · 4 comments
- [Stop Trusting AI Code Blindly: A React Code Refactoring Case Study](https://daily.dev/posts/stop-trusting-ai-code-blindly-a-react-code-refactoring-case-study-wibvkpwvb) · freeCodeCamp · 5 upvotes · 0 comments

---

Tags: [#react](https://daily.dev/tags/react), [#architecture](https://daily.dev/tags/architecture), [#tanstack](https://daily.dev/tags/tanstack), [#zustand](https://daily.dev/tags/zustand)

[View this post on daily.dev](https://daily.dev/posts/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-dgsuki7nv)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Refactoring a Messy React Workflow: From One Giant Modal to Independent Vertical Slices","url":"https://daily.dev/posts/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-dgsuki7nv","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-dgsuki7nv"},"datePublished":"2026-09-06T10:07:13.720Z","dateModified":"2026-09-14T07:33:26.686Z","description":"A deep, fictional case study walks through refactoring a single large React dialog component (a 'Catalog Setup Hub' handling product creation, file import, and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/91470bea536ee7d5ff8e987d3ad9b7f9?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/91470bea536ee7d5ff8e987d3ad9b7f9?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Medium","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Medium","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/medium","url":"https://daily.dev/sources/medium_js"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-dgsuki7nv","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"react,architecture,tanstack,zustand","timeRequired":"PT15M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Medium","item":"https://daily.dev/sources/medium_js"},{"@type":"ListItem","position":3,"name":"Refactoring a Messy React Workflow: From One Giant Modal to Independent Vertical Slices"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/refactoring-a-messy-react-workflow-from-one-giant-modal-to-independent-vertical-slices-dgsuki7nv#faq","mainEntity":[{"@type":"Question","name":"How do you handle partial failure in a React import workflow with retries?","acceptedAnswer":{"@type":"Answer","text":"Partial failure should be modeled as durable state rather than a generic error. When a batch import partially succeeds, successful items are merged by client ID and kept committed, while failed items remain visible; retry submits only items whose status is not 'succeeded'. Completion fires only once all items succeed, preserving already-committed results across retries. Developers designing resilient import flows can find deeper architecture breakdowns like this on daily.dev."}},{"@type":"Question","name":"Should TanStack Query own form state and draft data in a React mutation workflow?","acceptedAnswer":{"@type":"Answer","text":"No, TanStack Query should orchestrate the asynchronous transition, not own the form draft or persisted per-item statuses. A dedicated state slice (for example, a Zustand store) holds the draft and results, while the mutation's lifecycle callbacks (onMutate, onSuccess, onError, onSettled) coordinate running state, host notification, and duplicate-submit locking. Engineers weighing state ownership boundaries with TanStack Query can track patterns like this via daily.dev."}},{"@type":"Question","name":"How do you prove a React component refactor preserves the same behavior as the original?","acceptedAnswer":{"@type":"Answer","text":"Run both the legacy and refactored components through one shared black-box conformance test suite that interacts only through accessible labels, roles, and visible statuses, never through internal hooks or DOM details. Combine this with static architecture tests, such as invoking ESLint's Node API to assert that boundary-violating imports between slices are reported. Teams validating behavior-preserving refactors can explore similar testing strategies on daily.dev."}}]}
```

