A collection of 10 small React projects that demonstrate how to combine useContext and useReducer for global state management.
These projects are lightweight but cover real-world use cases like authentication, todo management, theming, and more.
useReducer: Manage theme state (light, dark).
useContext: Provide theme state globally to all components.
Scope:
- Toggle between light & dark mode.
- Save preference in
localStorage
. - Apply theme globally across components.
useReducer: Handle actions like ADD_TODO, TOGGLE_TODO, REMOVE_TODO, SET_FILTER
useContext: Share todos and filter state with all components.
Scope:
- Add, remove, and toggle todos.
- Filter:
All | Active | Completed
. - Global state shared across
TodoList
,TodoItem
, andFilter
.
useReducer: Actions for ADD_ITEM, REMOVE_ITEM, INCREASE_QTY, DECREASE_QTY
useContext: Share cart state across ProductList, Cart, and Navbar.
Scope:
- Add/Remove products to cart.
- Increase/Decrease quantity.
- Show cart count in Navbar & calculate total price.
useReducer: Actions like LOGIN, LOGOUT, REGISTER
useContext: Provide auth state globally.
Scope:
- Login, Logout, Register with global state.
- Show logged-in user in Navbar.
- Simple protected route handling.
useReducer: Actions like ADD_NOTE, DELETE_NOTE, SET_CATEGORY
useContext: Share notes + category across components.
Scope:
- Add notes with category (Work, Personal, etc.).
- Filter notes by category.
- Delete note functionality with persistence.
useReducer: Actions like NEXT_STEP, PREVIOUS_STEP, UPDATE_FIELD.
useContext: Share form data & current step across all form components.
Scope:
- Multi-step form (Personal Info → Address → Review).
- Navigate between steps.
- Collect all data in global state before submission.
useReducer: Actions like ADD_EXPENSE, DELETE_EXPENSE, FILTER_BY_CATEGORY.
useContext: Share balance, expenses, and filters globally.
Scope:
- Add expenses with amount & category.
- Show total spent & remaining balance.
- Filter by category and delete entries.
useReducer: Actions like ANSWER_QUESTION, NEXT_QUESTION, RESET_QUIZ.
useContext: Share current question & score globally.
Scope:
- Answer multiple-choice questions.
- Track score globally.
- Show results at the end.
useReducer: Actions like ADD_NOTIFICATION, REMOVE_NOTIFICATION.
useContext: Share notifications globally (accessible in Navbar, Sidebar, etc.).
Scope:
- Add notifications globally (success, error, info).
- Auto-dismiss after a few seconds.
- Display notifications anywhere in the app.
useReducer: Actions like ADD_SONG, REMOVE_SONG, PLAY_SONG, PAUSE_SONG.
useContext: Share playlist & current song globally.
Scope:
- Add/remove songs from a playlist.
- Mark currently playing song.
- Simple player controls (Play/Pause).
- React.js (with Hooks)
- useContext for global state sharing
- useReducer for action-based state management
- Material UI / Tailwind CSS (for styling)
Made with ❤️ by Tanmay Shil GitHub: @TanmayShil