-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Background color slice using redux toolkit
- Loading branch information
1 parent
b1a30e0
commit 2e9b6d2
Showing
10 changed files
with
111 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
lab3/src/components/BackgroundColorPicker/BackgroundColorPicker.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
|
||
const initialState = { | ||
// TODO: Task 2 | ||
bgColor: "gold", | ||
}; | ||
|
||
const backgroundSlice = createSlice({ | ||
name: "background", | ||
initialState, | ||
reducers: { | ||
updatedBackgroundColor(state, action) { | ||
state.bgColor = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { updatedBackgroundColor } = backgroundSlice.actions; | ||
|
||
export const selectBackgroundColor = (state) => state.background.bgColor; | ||
|
||
export default backgroundSlice.reducer; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
|
||
import { applyMiddleware, createStore } from "redux"; | ||
import { composeWithDevTools } from "redux-devtools-extension"; | ||
import logger from "redux-logger"; | ||
import thunk from "redux-thunk"; | ||
import rootReducer from "./reducers/reducers"; | ||
|
||
const configureStore = (preloadedState) => { | ||
|
||
const middleware = [ | ||
thunk, | ||
logger | ||
]; | ||
|
||
return createStore(rootReducer, preloadedState, composeWithDevTools(applyMiddleware(...middleware))); | ||
}; | ||
|
||
export default configureStore; | ||
import { configureStore } from "@reduxjs/toolkit"; | ||
import backgroundReducer from "./features/background/backgroundSlice"; | ||
import userReducer from "./reducers/userReducer"; | ||
|
||
const store = configureStore({ | ||
reducer: { | ||
background: backgroundReducer, | ||
users: userReducer, | ||
}, | ||
}); | ||
|
||
export default store; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"@reduxjs/toolkit": "^2.2.8" | ||
} | ||
} |