Last active
September 26, 2017 12:25
-
-
Save Bizunow/91e8617072d1711f741b832180cf5acc to your computer and use it in GitHub Desktop.
[React-Redux duck module] #js #react #redux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Actions | |
const ACTION_1 = "my-app/social/ACTION_1"; | |
// Dispatchers | |
export const dispatcher_1 = (data) => { | |
return (dispatch, getState) => { | |
dispatch({ type: ACTION_1, payload: data }); | |
}; | |
}; | |
const initialState = { | |
data: null | |
}; | |
export default (state = initialState, action) => { | |
switch (action.type) { | |
case ACTION_1: { | |
return { ...state, data: action.payload }; | |
} | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment