jfdesousa7 avatar

Tutorial - Breve Introducción a Redux

jfdesousa7

Published: 21 May 2022 › Updated: 21 May 2022Tutorial - Breve Introducción a Redux

Tutorial - Breve Introducción a Redux


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())


▶️ 3Speak

Leave Tutorial - Breve Introducción a Redux to:

Written by

Blockchain developer ~ website: tupaginaonline.net ~ Instagram : tupaginaonline_net ~ Tennis player in my free time

Read more #programming posts


Best Posts From jfdesousa7

We have not curated any of jfdesousa7's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From jfdesousa7