Fix: [Section] Scalable Application Structure - #340
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a documentation guide for a scalable, feature-based application structure in React and Redux projects, complete with code examples. The review feedback highlights a few inconsistencies and bugs in the provided code snippets: specifically, authSlice and authActions need to be properly exported from the slice file to match the public API exports, and a local logout function in the custom hook example needs to be renamed to avoid a shadowing issue that would cause an infinite loop at runtime.
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.
| error: null, | ||
| }; | ||
|
|
||
| const authSlice = createSlice({ |
There was a problem hiding this comment.
In features/auth/index.ts (line 61), authSlice is exported from ./slices/authSlice. However, in this code block, authSlice is declared as a local constant and not exported. Exporting it here will resolve the import error.
| const authSlice = createSlice({ | |
| export const authSlice = createSlice({ |
| export const { loginStart, loginSuccess, loginFailure, logout } = authSlice.actions; | ||
| export const authReducer = authSlice.reducer; |
There was a problem hiding this comment.
In features/auth/index.ts (line 61), authActions is exported from ./slices/authSlice. However, authActions is not defined or exported in authSlice.ts. Defining and exporting authActions here makes the public API export valid.
| export const { loginStart, loginSuccess, loginFailure, logout } = authSlice.actions; | |
| export const authReducer = authSlice.reducer; | |
| export const authActions = authSlice.actions; | |
| export const { loginStart, loginSuccess, loginFailure, logout } = authActions; | |
| export const authReducer = authSlice.reducer; |
| const logout = () => { | ||
| dispatch(logout()); | ||
| }; | ||
|
|
||
| return { login, logout, isAuthenticated, user }; |
There was a problem hiding this comment.
The local logout function shadows the imported logout action creator from ./slices/authSlice. Because of lexical scoping, calling dispatch(logout()) inside the local logout function will recursively call the local function itself instead of the action creator, leading to an infinite loop (Stack Overflow) at runtime. Renaming the local function to handleLogout avoids this shadowing issue.
| const logout = () => { | |
| dispatch(logout()); | |
| }; | |
| return { login, logout, isAuthenticated, user }; | |
| const handleLogout = () => { | |
| dispatch(logout()); | |
| }; | |
| return { login, logout: handleLogout, isAuthenticated, user }; |
|
Closing as duplicate. The latest fix is in PR #341. Apologies for the noise — improving the automation. |
Fixes #42
This PR addresses the IssueHunt-funded issue #42.