Skip to content

Fix: [Section] Scalable Application Structure - #338

Open
Ghostofcaldera wants to merge 1 commit into
piotrwitek:masterfrom
Ghostofcaldera:fix/issue-42-1781378636
Open

Fix: [Section] Scalable Application Structure#338
Ghostofcaldera wants to merge 1 commit into
piotrwitek:masterfrom
Ghostofcaldera:fix/issue-42-1781378636

Conversation

@Ghostofcaldera

Copy link
Copy Markdown

Fixes #42

This PR addresses the IssueHunt-funded issue #42.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +21 to +24
│ ├── auth/
│ │ ├── components/
│ │ │ ├── LoginForm.tsx
│ │ │ └── index.ts

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
│ ├── auth/
│ │ ├── components/
│ │ │ ├── LoginForm.tsx
│ │ │ └── index.ts
│ ├── auth/
│ │ ├── components/
│ │ │ ├── AuthFeature.tsx
│ │ │ ├── LoginForm.tsx
│ │ │ └── index.ts

Comment on lines +82 to +87
export const store = configureStore({
reducer: {
...(featureFlags.AUTH && { auth: authReducer }),
...(featureFlags.DASHBOARD && { dashboard: dashboardReducer }),
},
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Conditionally adding reducers to the store based on feature flags can lead to TypeScript compilation errors and runtime issues:

  1. Type Safety & RootState Consistency: If reducers are conditionally added, the inferred RootState type 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?.user instead of state.auth.user), which degrades developer experience and increases boilerplate.
  2. 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.

Suggested change
export const store = configureStore({
reducer: {
...(featureFlags.AUTH && { auth: authReducer }),
...(featureFlags.DASHBOARD && { dashboard: dashboardReducer }),
},
});
export const store = configureStore({
reducer: {
auth: authReducer,
dashboard: dashboardReducer,
},
});

@Ghostofcaldera

Copy link
Copy Markdown
Author

Summary

This PR addresses Issue #42 - Scalable Application Structure

Changes made:

  • Implements the requested changes as described in the issue
  • Follows existing code style and conventions
  • Ready for review

This PR is part of an IssueHunt-funded bounty ($60). Please review and merge at your convenience.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Section] Scalable Application Structure

1 participant