3
En el día de hoy quiero hablar de Redux.js redux es una librería de js que nos permite gestionar todos los estados de nuestra App. Voy a explicar de manera introductoria y superficial como funciona el flujo de redux.
Index.js
const redux = require("redux")
const createStore = redux.createStore
const SUMAR = "SUMAR"
const initialState = {
valor: 0,
usuarios: [],
isLoading: false
}
const sumando = () => {
return {
type: SUMAR
}
}
const reducer = ( (state = initialState , action) => {
switch(action.type){
case SUMAR : {
return {
...state, valor: state.valor + 1
}
}
default: return state
}
})
const store = createStore(reducer)
console.log(" ESTADO INICIAL ", store.getState())
store.subscribe( () => console.log(" ACTUALIZANDO ESTADO ", store.getState()))
store.dispatch(sumando())
Comments:
Reply:
To comment on this video please connect a HIVE account to your profile: Connect HIVE Account