-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathAppReducer.js
More file actions
34 lines (30 loc) · 809 Bytes
/
AppReducer.js
File metadata and controls
34 lines (30 loc) · 809 Bytes
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
30
31
32
33
34
// Import Actions
import { TOGGLE_ADD_POST, TOGGLE_ADD_COMMENT } from './AppActions';
// Initial State
const initialState = {
showAddPost: false,
showAddComment: false,
};
const AppReducer = (state = initialState, action) => {
switch (action.type) {
case TOGGLE_ADD_POST:
return {
showAddPost: !state.showAddPost,
showAddComment: state.showAddComment,
};
case TOGGLE_ADD_COMMENT:
return {
showAddPost: state.showAddPost,
showAddComment: !state.showAddComment,
};
default:
return state;
}
};
/* Selectors */
// Get showAddPost
export const getShowAddPost = state => state.app.showAddPost;
// Get showAddComment
export const getShowAddComment = state => state.app.showAddComment;
// Export Reducer
export default AppReducer;