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

203
Visualizações
UseSelector state undefined when accessing in component

When I try and destructure my data using useSelector, I get the error backgroundImage undefined.

I am setting my initial state in my reducer. How can I stop the error occurring?

component:

export const SampleScreen = (props) => {
  const { navigation } = props;

  const {
    rescueMe: {
      rescueMeSplashScreen: {
        backgroundImage, // error undefined
        buttonText,
        informationText,
        title: pageTitle,
      },
    },
  } = useSelector((state) => state);


  return (
    <>

    </>
  );
};

Reducer:

const RescueMeReducer = (
  state = {
    rescueMeSplashScreen: {
      backgroundImage: "",
      buttonText: "",
      informationText: "",
      title: "",
    },
    lastKnownPosition: undefined,
    error: undefined,
    loading: false,
  },
  action
) => {
  switch (action.type) {
    ...
    case RESCUE_ME_CONTENT: {
      return {
        ...state,
        error: undefined,
        rescueMeSplashScreen: undefined,
        loading: true,
      };
    }
    case RESCUE_ME_CONTENT_SUCCESS: {
      return {
        ...state,
        rescueMeSplashScreen: action.payload,
        loading: false,
      };
    }
    case RESCUE_ME_CONTENT_FAILED: {
      return {
        ...state,
        rescueMeSplashScreen: undefined,
        error: {
          errorMessage: action.payload,
        },
        loading: false,
      };
    }
    default:
      return state;
  }
};

export default RescueMeReducer;
about 4 years ago · Juan Pablo Isaza
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