Redux & Redux Toolkit
/Beginner
Feature-Based Structure
Definition
An organizational pattern where files are grouped by feature (e.g., Auth, Cart, Products) rather than by file type (e.g., Actions, Reducers, Components).
Explain Like I'm New
In the old days, you had an `actions` folder, a `reducers` folder, and a `components` folder. To edit the Shopping Cart, you had to open 3 different folders and jump between 3 files. Feature-based structure puts `CartComponent.js` and `cartSlice.js` together in one `features/cart/` folder.
Real World Example
The official recommendation by the Redux team. If you delete the `cart` folder, the entire cart feature is cleanly removed from the app without leaving orphaned code behind.
Common Use Cases
- •Project organization
- •Scaling codebases
Terminal Output
bash / terminal
/*
❌ BAD: Type-Based Structure (Hard to maintain)
src/
actions/
authActions.js
cartActions.js
reducers/
authReducer.js
cartReducer.js
components/
Login.jsx
Cart.jsx
✅ GOOD: Feature-Based Structure (Easy to maintain)
src/
features/
auth/
Login.jsx
authSlice.js
cart/
Cart.jsx
cartSlice.js
*/
Interview Questions
basic
- What is the opposite of Feature-Based folder structure?
intermediate
- What is the 'Ducks' pattern?