You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a React Native app (using TypeScript and RTK Query) in which I want to show an intro slider only for the first app launch and never show it again unless the app data is cleared. I have created a slice for its visibility state and am using redux-persist to keep the data.
Upon logout I'm reseting the store and redux-persist by following Dan's and Lenz's recommendations.
// Root reducer (resettable)
const rootReducer = (
state: ReturnType<typeof appReducer> | undefined,
action: AnyAction
) => {
// If the `logout` action is dispatched, clean the `Redux Persist` storage and reset the state
if (action.type === "auth/logout") {
storage.removeItem("persist:root");
return appReducer(undefined, action);
}
return appReducer(state, action);
};
I also have separated the persistence config of my intro slice so that I can keep it into storage.
interface IntroSliceState {
/** Whether to show the app intro slides or not */
showIntro: boolean;
}
const initialState: IntroSliceState = {
showIntro: true,
};
const introSlice = createSlice({
name: "intro",
initialState,
reducers: {
hideIntro: (state) => {
state.showIntro = false;
},
},
});
The problem I'm trying to solve now is to find a way to keep the intro slice from being cleared on logout and I know I have to modify this part: (return appReducer(undefined, action);) but I have no idea how to do it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have a React Native app (using TypeScript and RTK Query) in which I want to show an intro slider only for the first app launch and never show it again unless the app data is cleared. I have created a slice for its visibility state and am using
redux-persist
to keep the data.Upon logout I'm reseting the store and
redux-persist
by following Dan's and Lenz's recommendations.I also have separated the
persistence config
of my intro slice so that I can keep it into storage.And this is the
intro
slice:The problem I'm trying to solve now is to find a way to keep the
intro
slice from being cleared on logout and I know I have to modify this part: (return appReducer(undefined, action);
) but I have no idea how to do it.I'd appreciate any help!
Beta Was this translation helpful? Give feedback.
All reactions