Home > Software design >  How to print Array type data from console to mobile screen in React Native
How to print Array type data from console to mobile screen in React Native

Time:03-31

This is the response data from api

i want to add pagination in screen with this response , tried different tutorials but didn't solve my problem

CodePudding user response:

you can use something like {yourArray.map((item)=><Text>item</Text>)} inside of your screen to map the array to components, as for pagination you'll have to store the url to the next page in a state to be accessed the next time you wanna fetch.

CodePudding user response:

First of all, i think that will be great if you explain a little more about you dataset and you final objective.

In React Native, I usualy use <FlatList> to render a data list. (https://reactnative.dev/docs/flatlist)

The data props is you dataset, and the renderItem is the output for each data "row".

<FlatList
    data={DATA}
    renderItem={renderItem}
    keyExtractor={item => item.id}
/>

I noticed that your dataset contains some HTML contents. If you want to render this on this list, you'll have some issues, case the sintax its different and will.

  • Related