Files
DefectingCat 4db3db2a24 Fix menu list on mobile
* add ahooks library
* add useAppDispatch and useAppSelector hooks
* move out router event handle from useEffect
* fix router events off
2021-11-25 15:54:35 +08:00

29 lines
665 B
TypeScript

import { createSlice, PayloadAction } from '@reduxjs/toolkit';
export interface RouterState {
fromPath: string;
}
const initialState: RouterState = {
// Record the from path when into the post page.
fromPath: '',
};
export const routerSlice = createSlice({
name: 'router',
initialState,
reducers: {
setFromPath: (state, action: PayloadAction<string>) => {
state.fromPath = action.payload;
},
cleanFromPath: (state) => {
state.fromPath = '';
},
},
});
// Action creators are generated for each case reducer function
export const { setFromPath, cleanFromPath } = routerSlice.actions;
export default routerSlice.reducer;