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

100
Views
Get to array in react state

I am using redux for state management on react-native and I am a total rookie, be warned ;)

I am converting my static data to using the product state instead of an array.

This is my static product array which will later be fetched from an API.

    const products = [
       {id: 1, title: 'Apple Pie'},
    ];

On app load I set the state like this:

    useEffect(() => {
      dispatch(allActions.productActions.setProducts(products))
    },[]);

On my view I call the getItem function, which works fine with the static array

    function getItem(itemId) {
      let obj = products.filter(item => item.id === itemId);
      return obj[0];
    }

the function returns an undefined object error, because it expects the actual array and not the state object.

The products state looks like that:

 [{"products":[{"id":1,"title":"Apple Pie"}]}]

out of that I need:

[{"id":1,"title":"Apple Pie"}]
about 4 years ago · Santiago Trujillo
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!