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

197
Visualizações
I tried toggling the alarm button to checked button for the targeted task but is not working

I tried toggling the alarm button to check button for the targeted task but the alarm icon of all the tasks change too. Am using the redux toolkit

This is my state

const initialState = {
  isHideForm: false,
  taskDesc: "",
  date: "",
  time: "",
  user: "",
  taskTitle: "",
  isEditing: false,
  editID: null,
  isCompleted: false,
  data: [],
};

Here is the reducer for toggling the button

 completed(state, action) {
      let item = state.data.find((x) => x.id === action.payload);
      if (item) {
        state.isCompleted = !state.isCompleted;
      }
    },

This is the on-click button

<button onClick={(e) => handleCompleted(e, d.id)}
                className="border-y-2 border-r-2 border-gray-200 p-2 rounded-r">
                {isCompleted ? <GrCheckmark /> : <FaBell />}
              </button>
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You've to return a new state object

if(item) { 
return {...state, isCompleted: !state.isCompleted }
}
about 4 years ago · Santiago Trujillo 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