Last active
December 6, 2023 02:15
-
-
Save sametcn99/ddc2cf55d80d6c990d70e1db9e059644 to your computer and use it in GitHub Desktop.
redux-toolkit starter
This file contains hidden or 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
| "use client"; | |
| import { Provider } from "react-redux"; | |
| import reduxStore from "@/lib/redux/store"; | |
| export function Providers({ children }: { children: React.ReactNode }) { | |
| return <Provider store={reduxStore}>{children}</Provider>; | |
| } |
This file contains hidden or 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
| // Import the combineReducers function from Redux Toolkit to combine multiple reducers into a single root reducer | |
| import { combineReducers } from "@reduxjs/toolkit"; | |
| // Import individual slice reducers | |
| import counterReducer from "./slices/counterSlicer"; | |
| import userReducer from "./slices/userSlicer"; | |
| import todoReducer from "./slices/todoSlicer"; | |
| import searchReducer from "./slices/searchSlicer"; | |
| // Combine the individual reducers into a root reducer using combineReducers | |
| // The keys in the resulting state object will correspond to the names given to the individual reducers | |
| const rootReducer = combineReducers({ | |
| counter: counterReducer, // Reducer for managing counter-related state | |
| user: userReducer, // Reducer for managing user-related state | |
| todo: todoReducer, // Reducer for managing todo's | |
| search: searchReducer, // Reducer for managing search state | |
| }); | |
| // Export the combined root reducer as the default export of this module | |
| export default rootReducer; |
This file contains hidden or 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
| // Import the combineReducers function from Redux Toolkit to combine multiple reducers into a single root reducer | |
| import { combineReducers } from "@reduxjs/toolkit"; | |
| // Import individual slice reducers | |
| import counterReducer from "./slices/counterSlicer"; | |
| import userReducer from "./slices/userSlicer"; | |
| import todoReducer from "./slices/todoSlicer"; | |
| import searchReducer from "./slices/searchSlicer"; | |
| // Combine the individual reducers into a root reducer using combineReducers | |
| // The keys in the resulting state object will correspond to the names given to the individual reducers | |
| const rootReducer = combineReducers({ | |
| counter: counterReducer, // Reducer for managing counter-related state | |
| user: userReducer, // Reducer for managing user-related state | |
| todo: todoReducer, // Reducer for managing todo's | |
| search: searchReducer, // Reducer for managing search state | |
| }); | |
| // Export the combined root reducer as the default export of this module | |
| export default rootReducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment