Last active
February 1, 2018 15:36
-
-
Save marensas/21b04d3052eca7c01a02de5cab560969 to your computer and use it in GitHub Desktop.
Actions
This file contains 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
// 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