Skip to content

Commit f1037fb

Browse files
refactor(nodes): add initialState and action type
1 parent 70959ab commit f1037fb

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/store/reducers/nodes.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import '../../services/api';
33

44
const FETCH_NODES = createRequestActionTypes('nodes', 'FETCH_NODES');
55

6-
const nodes = function z(state = {loading: true, wasLoaded: false}, action) {
6+
const CLEAR_NODES = 'nodes/CLEAR_NODES';
7+
8+
const initialState = {
9+
loading: true,
10+
wasLoaded: false,
11+
};
12+
13+
const nodes = (state = initialState, action) => {
714
switch (action.type) {
815
case FETCH_NODES.REQUEST: {
916
return {
@@ -28,7 +35,7 @@ const nodes = function z(state = {loading: true, wasLoaded: false}, action) {
2835
loading: false,
2936
};
3037
}
31-
case 'CLEAR_NODES': {
38+
case CLEAR_NODES: {
3239
return {
3340
...state,
3441
loading: true,
@@ -50,6 +57,6 @@ export function getNodes(path) {
5057
});
5158
}
5259

53-
export const clearNodes = () => ({type: 'CLEAR_NODES'});
60+
export const clearNodes = () => ({type: CLEAR_NODES});
5461

5562
export default nodes;

0 commit comments

Comments
 (0)