notification store and update in local storage

This commit is contained in:
Jaanu423
2025-10-07 15:33:24 +05:30
parent d197e31acb
commit 80fdb77590
12 changed files with 375 additions and 47 deletions
+47 -10
View File
@@ -1,13 +1,50 @@
// store.ts
import { configureStore } from "@reduxjs/toolkit";
import userReducer from "./userSlice"; // adjust the path
// // store.ts
// import { configureStore } from "@reduxjs/toolkit";
// import userReducer from "./userSlice"; // adjust the path
export const store = configureStore({
reducer: {
user: userReducer, // register user slice here
},
// export const store = configureStore({
// reducer: {
// user: userReducer, // register user slice here
// },
// });
// // ✅ Types for TypeScript
// export type RootState = ReturnType<typeof store.getState>;
// export type AppDispatch = typeof store.dispatch;
import { configureStore, combineReducers } from '@reduxjs/toolkit';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { persistReducer, persistStore } from 'redux-persist';
// import slices
import userReducer from './userSlice';
import notificationReducer from './notificationSlice';
// combine reducers
const rootReducer = combineReducers({
user: userReducer,
notifications: notificationReducer,
});
// ✅ Types for TypeScript
export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch;
// persist configuration
const persistConfig = {
key: 'root',
storage: AsyncStorage,
whitelist: ['user', 'notifications'], // persist both slices
};
// wrap root reducer with persistReducer
const persistedReducer = persistReducer(persistConfig, rootReducer);
// configure store
export const store = configureStore({
reducer: persistedReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
serializableCheck: false,
}),
});
export const persistor = persistStore(store);