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

220
Views
React native no puede encontrar datos de paginación y obtener un error de renderizado

Estoy tratando de obtener datos de paginación. primero, obtendrá datos de https://myapi/?page=1 luego https://myapi/?page=2 https://myapi/?page=3 algo así, pero no entiendo por qué obtengo este error

 TypeError: undefined is not an object (evaluating 'iter[Symbol.iterator]') This error is located at: in Blog (created by SceneView) in StaticContainer in EnsureSingleNavigator (created by SceneView) in SceneView (created by BottomTabView) in RCTView (created by View) in View (created by Screen) in RCTView (created by View) in View (created by Background) in Background (created by Screen) in Screen (created by BottomTabView) in RNSScreen (created by AnimatedComponent) in AnimatedComponent in AnimatedComponentWrapper (created by Screen) in MaybeFreeze (created by Screen) in Screen (created by MaybeScreen).....

aquí está mi código:

 const Blog = () => { const [data, setData] = useState([]); const [count, setCount] = useState(1); const getBlogs = async () => { try { const response = await fetch( `https://..../blog-api/?page=${count + 1}` ); setCount(count + 1); const json = await response.json(); setData((prev) => [...prev, ...json.results]); } catch (error) { console.error(error); } finally { setLoading(false); } }; useEffect(() => { getBlogs(); }, [count]); return ( <> <FlatList data={data} keyExtractor={({ id }, index) => id} renderItem={({ item }) => (......my oheres code

aquí está mi respuesta API parece:

 Object { "count": 4, "next": "https://..../blog-api/?page=4", "previous": "https://backendapi.farhyn.com/blog-api/?page=2", "results": Array [ Object { "author_first_name": "Mickel", "author_last_name": "HARTHO", "blog_body": "<p>test helo blog</p>", },
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Registre la respuesta que recibe de response.json(). Creo que te estás equivocando aquí.

 const json = await response.json(); setData((prev) => [...prev, ...json.results]);

El motivo de este error es que está asignando un solo objeto a FlatList Data en lugar de una matriz.

Asegúrese de tener una matriz en los datos. Razón: setData({})

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!