Skip to content

Instantly share code, notes, and snippets.

@diego3g
Created October 20, 2017 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diego3g/c4e22ab3f76e73107152647895e355ce to your computer and use it in GitHub Desktop.
Save diego3g/c4e22ab3f76e73107152647895e355ce to your computer and use it in GitHub Desktop.
// store/ducks/auth.js
// Action Types
export const Types = {
LOGIN: 'auth/LOGIN',
LOGOUT: 'auth/LOGOUT',
};
// Reducer
const initialState = {
isLogged: false,
token: null,
user: {},
};
export default function reducer(state = initialState, action) {
switch (action.type) {
case Types.LOGIN:
return {...};
case Types.LOGOUT:
return {...};
default:
return state;
}
}
// Action Creators
export function login(username, password) {
return {
type: Types.LOGIN,
payload: {
username,
password
},
}
}
export function logout() {
return {
type: Types.LOGOUT,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment