26 lines
625 B
TypeScript
26 lines
625 B
TypeScript
import {createSlice} from "@reduxjs/toolkit";
|
|
import type {RootState} from "./store";
|
|
|
|
const initialState = {
|
|
switchState: true,
|
|
}
|
|
export const ChangeSwitchState = createSlice({
|
|
name: 'ChangeSwitchState',
|
|
initialState,
|
|
reducers: {
|
|
ChangeSwitch: (state) => {
|
|
if (state.switchState) {
|
|
state.switchState = false;
|
|
} else {
|
|
state.switchState = true;
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
export const {ChangeSwitch} = ChangeSwitchState.actions;
|
|
|
|
export const selectSwitchState = (state: RootState) => state.ChangeSwitchState.switchState;
|
|
|
|
export default ChangeSwitchState.reducer;
|