Skip to content

Instantly share code, notes, and snippets.

@sametcn99
Last active December 6, 2023 02:15
Show Gist options
  • Select an option

  • Save sametcn99/ddc2cf55d80d6c990d70e1db9e059644 to your computer and use it in GitHub Desktop.

Select an option

Save sametcn99/ddc2cf55d80d6c990d70e1db9e059644 to your computer and use it in GitHub Desktop.
redux-toolkit starter
"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>;
}
// 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;
// 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