Fix: [Section] Scalable Application Structure - #335
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 and Redux applications. The reviewer provided valuable feedback to improve the code examples, including initializing the dynamic reducer configuration with a core placeholder reducer to prevent runtime errors when all optional features are disabled, and adding a missing import statement for configureStore in one of the example snippets.
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.
| const featureReducers: Record<string, any> = {}; | ||
|
|
||
| if (ENABLE_AUTH) { | ||
| featureReducers.auth = authReducer; | ||
| } | ||
|
|
||
| if (ENABLE_DASHBOARD) { | ||
| featureReducers.dashboard = dashboardReducer; | ||
| } |
There was a problem hiding this comment.
If both ENABLE_AUTH and ENABLE_DASHBOARD are set to false, featureReducers will be an empty object {}. Passing an empty object to configureStore will cause Redux's combineReducers to throw a runtime error (e.g., "Store does not have a valid reducer").
To prevent this, you should initialize featureReducers with a core/static reducer or a placeholder reducer so that the store always has at least one valid reducer.
| const featureReducers: Record<string, any> = {}; | |
| if (ENABLE_AUTH) { | |
| featureReducers.auth = authReducer; | |
| } | |
| if (ENABLE_DASHBOARD) { | |
| featureReducers.dashboard = dashboardReducer; | |
| } | |
| const featureReducers: Record<string, any> = { | |
| _core: (state = {}) => state, | |
| }; | |
| if (ENABLE_AUTH) { | |
| featureReducers.auth = authReducer; | |
| } | |
| if (ENABLE_DASHBOARD) { | |
| featureReducers.dashboard = dashboardReducer; | |
| } |
| import { authReducer, useAuth } from '@myapp/auth-feature'; | ||
|
|
||
| const store = configureStore({ | ||
| reducer: { | ||
| auth: authReducer, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
The code snippet uses configureStore but does not import it. To make the example complete and copy-pasteable, please add the import statement for configureStore from @reduxjs/toolkit.
| import { authReducer, useAuth } from '@myapp/auth-feature'; | |
| const store = configureStore({ | |
| reducer: { | |
| auth: authReducer, | |
| }, | |
| }); | |
| import { configureStore } from '@reduxjs/toolkit'; | |
| import { authReducer, useAuth } from '@myapp/auth-feature'; | |
| const store = configureStore({ | |
| reducer: { | |
| auth: authReducer, | |
| }, | |
| }); |
|
Hi @piotrwitek, this PR is ready for review and addresses an IssueHunt bounty. Please review and merge when you have a moment. Thank you! |
|
Closing as duplicate. The latest fix is in PR #338. Apologies for the noise — improving the automation. |
Fixes #42
This PR addresses the IssueHunt-funded issue #42.