Fix #42: Add Scalable Application Structure section to README#313
Fix #42: Add Scalable Application Structure section to README#313gfgf-brain wants to merge 4 commits into
Conversation
- Feature-based folder layout with per-feature index.ts public API - Redux Toolkit slice + selector pattern per feature - Store registration: add/remove feature = 1 line in rootReducer - Dynamic reducer injection for on-demand feature loading - Shared/ convention for cross-feature utilities Closes piotrwitek#42
There was a problem hiding this comment.
Code Review
This pull request adds a new section to the README documenting a scalable, feature-based application structure for React, Redux, and TypeScript. The feedback identifies missing imports and exports in the README code snippets (such as combineReducers and RootState) and requests the removal of two accidentally committed scratchpad/tool-call files (brain_solution_42.md and brain_solution_42.py).
| // app/rootReducer.ts | ||
| import { counterReducer } from '../features/counter'; | ||
| import { authReducer } from '../features/auth'; | ||
|
|
||
| const rootReducer = combineReducers({ |
There was a problem hiding this comment.
The combineReducers function is used in app/rootReducer.ts but is not imported. Please import it from @reduxjs/toolkit (or redux) to avoid a runtime ReferenceError.
| // app/rootReducer.ts | |
| import { counterReducer } from '../features/counter'; | |
| import { authReducer } from '../features/auth'; | |
| const rootReducer = combineReducers({ | |
| // app/rootReducer.ts | |
| import { combineReducers } from '@reduxjs/toolkit'; | |
| import { counterReducer } from '../features/counter'; | |
| import { authReducer } from '../features/auth'; | |
| const rootReducer = combineReducers({ |
| // app/store.ts | ||
| import { configureStore, Reducer, AnyAction } from '@reduxjs/toolkit'; | ||
| import rootReducer, { RootState } from './rootReducer'; |
There was a problem hiding this comment.
There are two issues in this code snippet:
combineReducersis used ininjectReducerbut is not imported.RootStateis imported bycounterSelectors.tsfrom../../app/store, butapp/store.tsdoes not export it.
Importing combineReducers and exporting RootState from app/store.ts resolves both issues.
| // app/store.ts | |
| import { configureStore, Reducer, AnyAction } from '@reduxjs/toolkit'; | |
| import rootReducer, { RootState } from './rootReducer'; | |
| // app/store.ts | |
| import { configureStore, Reducer, AnyAction, combineReducers } from '@reduxjs/toolkit'; | |
| import rootReducer, { RootState } from './rootReducer'; | |
| export type { RootState }; |
| <!-- Brain solution for: [Section] Scalable Application Structure | ||
| <!-- Approach: Implement a modular, feature-based structure using lazy-loaded feature modules and a centralized feature registry. --> |
| <minimax:tool_call> | ||
| invoke="browse_github_repo" | ||
| parameters: | ||
| {"repo": "piotrwitek/react-redux-typescript-guide", "top_n": 100, "cutoff": 0} |
|
Addressed all review feedback in commit bc4ee3c. |
…chpad files
- rootReducer.ts snippet: add `import { combineReducers } from '@reduxjs/toolkit'`
- store.ts snippet: add combineReducers to import, add `export type { RootState }`
- Delete brain_solution_42.md and brain_solution_42.py
Closes #42
Changes
Adds a Scalable Application Structure section to
README.mdcovering:index.tsPayloadAction<T>— complete counter feature examplerootReducer.tsinjectReducer()for enabling features on demand (admin roles, lazy-loaded modules)src/shared/for cross-feature components/hooks/utilsTesting