4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

Tutorial - Breve Introducción a Redux

▶️ Watch on 3Speak


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

93 upvotes $2.38

Replies (3)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: