Fix: [Section] Scalable Application Structure - #338
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new documentation file outlining a scalable, feature-based directory structure and architecture for React/Redux applications. The feedback suggests aligning the directory structure example with the code snippets by adding AuthFeature.tsx, and warns against conditionally registering Redux reducers based on feature flags, as this practice compromises type safety and can trigger TypeScript compilation errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| │ ├── auth/ | ||
| │ │ ├── components/ | ||
| │ │ │ ├── LoginForm.tsx | ||
| │ │ │ └── index.ts |
There was a problem hiding this comment.
There is an inconsistency between the recommended directory structure and the code examples provided later in the document.
The directory structure lists LoginForm.tsx under auth/components/, but the code examples on lines 95-96 and 121 reference AuthFeature (e.g., import { AuthFeature } from './features/auth').
To maintain consistency, please update the directory structure to include AuthFeature.tsx or update the code examples to use LoginForm.
| │ ├── auth/ | |
| │ │ ├── components/ | |
| │ │ │ ├── LoginForm.tsx | |
| │ │ │ └── index.ts | |
| │ ├── auth/ | |
| │ │ ├── components/ | |
| │ │ │ ├── AuthFeature.tsx | |
| │ │ │ ├── LoginForm.tsx | |
| │ │ │ └── index.ts |
| export const store = configureStore({ | ||
| reducer: { | ||
| ...(featureFlags.AUTH && { auth: authReducer }), | ||
| ...(featureFlags.DASHBOARD && { dashboard: dashboardReducer }), | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Conditionally adding reducers to the store based on feature flags can lead to TypeScript compilation errors and runtime issues:
- Type Safety & RootState Consistency: If reducers are conditionally added, the inferred
RootStatetype will either lack these keys or mark them as optional. This forces all selectors across the application to perform defensive null/undefined checks (e.g.,state.auth?.userinstead ofstate.auth.user), which degrades developer experience and increases boilerplate. - TypeScript Spread Error: Spreading a boolean expression like
...(featureFlags.AUTH && { auth: authReducer })can trigger TypeScript compiler errors (e.g.,Spread types may only be created from object types) depending on the compiler configuration.
Recommendation:
Keep the Redux store schema static and consistent. Register all reducers unconditionally so that the state shape and TypeScript types remain stable. Use feature flags solely to control UI rendering, routing, and middleware/epic execution.
| export const store = configureStore({ | |
| reducer: { | |
| ...(featureFlags.AUTH && { auth: authReducer }), | |
| ...(featureFlags.DASHBOARD && { dashboard: dashboardReducer }), | |
| }, | |
| }); | |
| export const store = configureStore({ | |
| reducer: { | |
| auth: authReducer, | |
| dashboard: dashboardReducer, | |
| }, | |
| }); |
SummaryThis PR addresses Issue #42 - Scalable Application Structure Changes made:
This PR is part of an IssueHunt-funded bounty ($60). Please review and merge at your convenience. Thank you! |
Fixes #42
This PR addresses the IssueHunt-funded issue #42.