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

171
Vistas
TypeError: Cannot read properties of undefined (reading 'roomId')

I'm trying to get the roomId from firestore but I'm stuck with this problem since last week I have tried different es6 syntax to overcome with but no result. Below I have provided the code it shows the error on selectRoomId

import { createSlice } from '@reduxjs/toolkit';

export const appSlice = createSlice({
  name: 'app',
  initialState: {
    roomId: null
  },
  reducers: {
    enterRoom: (state, action) => {
      state.roomId = action.payload.roomId;
    },
  },
});

export const { enterRoom } = appSlice.actions;
export const selectRoomId = state => state.app.roomId;
export default appSlice.reducer;
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Spread your state and update the roomId only

reducers: {
  enterRoom: (state, action) => {
    ...state,
    roomId: action?.payload?.roomId;
  },
},
about 4 years ago · Juan Pablo Isaza Denunciar

0

Console log to check what you get from the store object by changing the state to

export const state = (state) => state; 

this helped me, I was facing the same issue.

#Inside Component

const roomId = useSelector(state);
console.log(roomId);

#What I get from console

{user:{roomId: null}
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