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

107
Views
Javascript Promise.all resulta de obtener varias API que no se representan en React Native FlatList

Estoy usando Promise.all para obtener varias API.

 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])

Cuando console.log (resultados), obtengo todas las matrices de objetos de apis

El problema es que cuando creo una FlatList, no obtengo nada para mostrar en la pantalla (en blanco)

 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> }} /> ) };

}

exportar ListScreen predeterminado;

¿Qué estoy haciendo mal?

Por favor ayuda. :(

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Necesita re-render el componente, para eso tendrá que usar los Hooks de reacción.

Así es como se verá el componente

 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> }} /> ) };

Uso

 <RetrieveAll />

E intente no crear elementos JSX async .

about 4 years ago · Juan Pablo Isaza Report
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!