jfdesousa7 3Speak Podcast

Tutorial - Breve Introducción a Redux


Listen Later

https://3speak.tv/watch?v=jfdesousa7/wrwvtuje
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())

...more
View all episodesView all episodes
Download on the App Store

jfdesousa7 3Speak PodcastBy jfdesousa7