-
Notifications
You must be signed in to change notification settings - Fork 11
/
About.ts
29 lines (25 loc) · 878 Bytes
/
About.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Reducer } from 'redux';
import { produce } from 'immer';
// == state ========================================================================================
export interface State {
isVisible: boolean;
}
export const initialState: Readonly<State> = {
isVisible: false
};
// == action =======================================================================================
export type Action = {
type: 'About/Open';
} | {
type: 'About/Close';
};
// == reducer ======================================================================================
export const reducer: Reducer<State, Action> = ( state = initialState, action ) => {
return produce( state, ( newState: State ) => {
if ( action.type === 'About/Open' ) {
newState.isVisible = true;
} else if ( action.type === 'About/Close' ) {
newState.isVisible = false;
}
} );
};