Skip to content

Instantly share code, notes, and snippets.

@marensas
Last active February 1, 2018 15:36
Show Gist options
  • Save marensas/21b04d3052eca7c01a02de5cab560969 to your computer and use it in GitHub Desktop.
Save marensas/21b04d3052eca7c01a02de5cab560969 to your computer and use it in GitHub Desktop.
Actions
// src/actions/index.js //
// Paprastas objektas su tipu ir perduodama informacija
export const addInfo = info => ({
type: 'ADD_INFO',
info
});
// src/reducers.index.js //
const initialState = 'pirmi duombazes duomenys';
const rootReducer = (state = initialState, action) => {
// switch pagalba filtruojame action'o tipa
// ir graziname nauja informacija
switch (action.type) {
case 'ADD_INFO':
return action.info;
default:
// visada nurodome default grazinima
// tuo atveju jei nepavyktu atpazinti tipo
return state;
}
}
export default rootReducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment