Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
action.payload.descrition shows 'undefined' when using redux

Hello I'm new to redux and this is my first redux code.

My index.js:

    import store from './store'

    store.dispatch({
        type:"bugAdded",
        payload: {
          decription: "THIS"
        }
     });

My reducer.js:


let lastId = 0;

function reducer(state = [], action) {
  switch (action.type) {
    case 'bugAdded':
      return [
        ...state,
        {
          id: ++lastId,
          description: action.payload.description,
          resolved: false,
        }
      ];
    case 'bugRemoved':
      return state.filter(bug => bug.id !== action.payload.id)
    default:
      return state
  }
}

export default reducer

console.log(store.getState());

My store.js:

import { createStore } from 'redux'
import reducer from './reducer'

const store = createStore(reducer);

export default store

As per the tutorial I'm supposed to get

description: THIS

in console log, whereas I'm getting

description: undefined

console.log screenshot

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You have a typo. You're dispatching:

payload: {
          decription: "THIS"
        }

it should be description instead.

Also, note that the style of Redux code you're writing is very outdated. Today we teach using our official Redux Toolkit package as the standard approach for using Redux, which will simplify all of the code in your app (even in this small example).

See the official Redux docs tutorials for details:

https://redux.js.org/tutorials/index

about 4 years ago · Juan Pablo Isaza Denunciar

0

import store from './store'

store.dispatch({ type:"bugAdded", payload: { decription: "THIS" } });

in you index.js file, you type wrong decription it must be description

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda