Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda