Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion week05/todo-project/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function App() {
);
}, []);

const editTodo = useCallback((id, newText) => {
const editTodo = useCallback((id, newText) => {
setTodos((prev) =>
prev.map((todo) => (todo.id === id ? { ...todo, text: newText } : todo)),
);
Expand Down
112 changes: 111 additions & 1 deletion week07/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions week07/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@reduxjs/toolkit": "^2.12.0",
"axios": "^1.16.0",
"react": "^19.2.6",
"react-dom": "^19.2.6",
Expand Down
40 changes: 16 additions & 24 deletions week07/src/redux/store.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
import { combineReducers, createStore } from "redux";
import { configureStore, createSlice } from "@reduxjs/toolkit";

const TOGGLE_THEME = "theme/toggle";

const initialThemeState = {
mode: "dark",
};

function themeReducer(state = initialThemeState, action) {
switch (action.type) {
case TOGGLE_THEME:
return {
...state,
mode: state.mode === "dark" ? "light" : "dark",
};
default:
return state;
}
}

const rootReducer = combineReducers({
theme: themeReducer,
const themeSlice = createSlice({
name: "theme",
initialState: {
mode: "dark",
},
reducers: {
toggleTheme: (state) => {
state.mode = state.mode === "dark" ? "light" : "dark";
},
},
});

export const store = createStore(rootReducer);
export const { toggleTheme } = themeSlice.actions;

export const toggleTheme = () => ({
type: TOGGLE_THEME,
export const store = configureStore({
reducer: {
theme: themeSlice.reducer,
},
});
Loading