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

221
Vistas
Why can't I set a file type variable in the redux toolkit state?

I'm trying to set a file inside a slice with redux-toolkit but it doesn't work.

First, here is my slice file

import { createSlice } from "@reduxjs/toolkit"

export const assignorsSlice = createSlice({
  name: "assignors",
  initialState: {
    list: [],
    assignorFileSignToUpdate: null,
  },
  reducers: {
    getAssignorsList: (state) => {
      return state.list
    },
    setAssignorsList: (state, action) => {
      state.list = action.payload
    },
    addAssignor: (state, action) => {
      state.list.push(action.payload)
    },
    toggleAssignor: (state, action) => {
      const rut = action.payload
      const assignor = state.list.find((assignor) => {
        return assignor.rut === rut
      })
      assignor.active = !assignor.active
    },
    setAssignorFileSignToUpdate: (state, action) => {
      state.assignorFileSignToUpdate = action.payload
      console.log(
        "🚀 ~ file: assignors.js ~ line 28 ~ action.payload",
        action.payload
      )
      console.log(
        "🚀 ~ file: assignors.js ~ line 29 ~ state.assignorFileSignToUpdate",
        state.assignorFileSignToUpdate
      )
    },
    getAssignorFileSignToUpdate: (state) => {
      return state.assignorFileSignToUpdate
    },
  },
})

// export actions
export const {
  setAssignorsList,
  addAssignor,
  toggleAssignor,
  getAssignorsList,
  setAssignorFileSignToUpdate,
  getAssignorFileSignToUpdate,
} = assignorsSlice.actions

export default assignorsSlice.reducer

The problem is in the setAssignorFileSignToUpdate action, I logged the payload and the state variable. The payload and the state in the console.log are correct, but the redux chrome extensión shows the assignorFileSignToUpdate variable with an empty object (see the image).

console and redux screenshot

In the slice file the assignorFileSignToUpdate variable is a file (the console.log shows it), but in the redux chrome extension is not, and when I call the useSelector to see this variable is an empty object too.

I don't know why this is happening, if you guys know the mistake I made or a way to fix it I would really appreciate it. Thanks in advance.

about 4 years ago · Santiago Trujillo
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