Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!