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

111
Vistas
Javascript Promise.all results from fetching multiple apis not rendering in the React Native FlatList

I am using Promise.all in order to fetch multiple apis.

const ListScreen = () => {

const first = fetch('https://EXAMPLEAPI').then(resp => resp.json())
const second = fetch('https://EXAMPLEAPI').then(resp => resp.json())
const third = fetch('https://EXAMPLEAPI').then(resp => resp.json())

const retrieveAll = async function () {
    let results = await Promise.all([first, second, third])

When console.log(results), I get all arrays of objects from apis

The problem is that when I create a FlatList, I don't get anything to be rendered on the screen(blank)

const retrieveAll = async function () {
    let results = await Promise.all([first, second, third])

    return (
        <FlatList
            keyExtractor={item => item.title}
            data={results}
            renderItem={({ item }) => {
                return <Text>{item.title}</Text>
            }}
        />
    )
};

}

export default ListScreen;

What am I doing wrong?

Please help. :(

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to re-render the component, for that you will have to use react Hooks.

This is how the component will look like

const RetrieveAll = function () {
    const [ results, setResults ] = useState([])
    useEffect( () => {
        Promise.all([first, second, third])
        .then(response => {
           setResults(response)
        })

    }, [])

    return (
        <FlatList
            keyExtractor={item => item.title}
            data={results}
            renderItem={({ item }) => {
                return <Text>{item.title}</Text>
            }}
        />
    )
};

Usage

<RetrieveAll />

And try not to create async JSX elements.

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