React & Modern Frontend (445 Qs)•Part 10: Modern React 18, React 19 & Next.js Patterns (317 - 353)
How would you structure Redux in a large application?
The recommended approach (and what Redux Toolkit is designed around) is a "feature folder" / "ducks" structure rather than splitting by technical type (actions/, reducers/, constants/):
bash
src/
app/
store.js # configureStore() + root reducer wiring
features/
posts/
postsSlice.js # createSlice: reducer + actions + thunks
postsSelectors.js # createSelector-based selectors
PostList.jsx # components using useSelector/useDispatch
users/
usersSlice.js
usersSelectors.js
Guidelines:
- Colocate a feature's slice, selectors, thunks, and components in one folder instead of scattering related code across parallel
actions/reducers/constantsfolders. - One slice per domain concept (posts, users, cart), created with
createSlice, combined once instore.js. - Keep components decoupled from the store shape by reading data only through selectors, never
state.posts.entitiesdirectly in a component. - Normalize related/nested data (see Q336) so features can reference each other by ID instead of duplicating data.
- Use RTK Query (or a dedicated API slice) for server state, and keep hand-written slices for genuine client/app state.