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

149
Vistas
How do i update object in redux

I would like to update an object in the middle of processing redux I need to check if this is first time for a function.

here is my code.

const initialState = {
  table: [],
  timer: 0,
  result: "",
  gameState: false,
  openedCount: 0,
  isFirst: true
};

what I tried

if(state.isFirst) {
   state.isFirst = false;
}

How do I update like that in redux? just want to update for isFirst not returning state.

I will return { ...state, table: newArray }

I would really appreciate your help thanks for reading my question.

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

0

you can write this condition :

if(state.isFirst) {
   state.isFirst = false;
}

in each switch case : and update your state accordingly .

For example :

const initialState = {
  table: [],
  timer: 0,
  result: "",
  gameState: false,
  openedCount: 0,
  isFirst: true
};
const Reducer(state=initialState,action)=>{
   switch(action.type){
      case "first" : 
           if(state.isFirst) {
              state.isFirst = false;
              // update the new state
           }       
      case "second" : 
           if(state.isFirst) {
              state.isFirst = false;
              // update the new state
           }   
      default : return;        
   }
}
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