{"id":1172,"date":"2023-01-02T19:51:41","date_gmt":"2023-01-02T18:51:41","guid":{"rendered":"https:\/\/codeflarelimited.com\/blog\/?p=1172"},"modified":"2023-01-02T19:51:43","modified_gmt":"2023-01-02T18:51:43","slug":"fetch-data-from-an-api-and-display-in-flatlist-in-react-native","status":"publish","type":"post","link":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/","title":{"rendered":"Fetch Data From an API and Display in FlatList in React Native"},"content":{"rendered":"\n<p>The FlatList component is an effective way to display items in a scrollable list view. We can fetch data from an API and display in FlatList in React Native.  It is a useful alternative to ScrollViews, especially when dealing with large data sets.<\/p>\n\n\n\n<p>Flat lists, has the following features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Fully cross-platform.<\/li>\n\n\n\n<li>Optional horizontal mode.<\/li>\n\n\n\n<li>Configurable viewability callbacks.<\/li>\n\n\n\n<li>Header support.<\/li>\n\n\n\n<li>Footer support.<\/li>\n\n\n\n<li>Separator support.<\/li>\n\n\n\n<li>Pull to Refresh.<\/li>\n\n\n\n<li>Scroll loading.<\/li>\n\n\n\n<li>ScrollToIndex support.<\/li>\n\n\n\n<li>Multiple column support.<\/li>\n<\/ul>\n\n\n\n<p>In this article, we shall see how we can fetch data from an endpoint and display the data using FlatList in React Native.<\/p>\n\n\n\n<p>So, I will assume that you already know how to create a new React Native application. If you&#8217;re just getting started, you can check out the article on creating a new React Native project <a href=\"https:\/\/codeflarelimited.com\/blog\/getting-started-with-react-native-create-a-class-component\/\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>Here&#8217;s what a new React Native application should look like:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-13.53.35-473x1024.png\" alt=\"\" class=\"wp-image-1173\" width=\"286\" height=\"618\" srcset=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-13.53.35-473x1024.png 473w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-13.53.35-139x300.png 139w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-13.53.35-768x1662.png 768w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-13.53.35-710x1536.png 710w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-13.53.35-946x2048.png 946w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-13.53.35.png 1170w\" sizes=\"auto, (max-width: 286px) 100vw, 286px\" \/><figcaption class=\"wp-element-caption\">React Native application<\/figcaption><\/figure>\n\n\n\n<p>We are going to be fetching data from the <a href=\"https:\/\/catfact.ninja\/#\/Breeds\/getBreeds\" target=\"_blank\" rel=\"noreferrer noopener\">Cat Facts API<\/a>. So we will write our React Native code as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">fetchItem() {\n      requestAnimationFrame(() =&gt;\n        fetch(`https:\/\/catfact.ninja\/breeds`, {\n          method: 'GET',\n        })\n          .then(response =&gt; response.json())\n          .then(responseJson =&gt; {\n             console.warn(responseJson);\n          })\n          .catch(error =&gt; {\n            {\n              alert(error)\n            }\n          }),\n      );\n  }\n\n  componentDidMount(){\n    this.fetchItem()\n  }\n<\/code><\/pre>\n\n\n\n<p>Let&#8217;s explain what&#8217;s happening here.<\/p>\n\n\n\n<p>Here, we&#8217;re calling the endpoint <a href=\"https:\/\/catfact.ninja\/breeds\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/catfact.ninja\/breeds <\/a>and logging the response to at least confirm that we&#8217;re even getting a response. We&#8217;re then calling that method in our <em><strong>componentDidMount()<\/strong><\/em><\/p>\n\n\n\n<p>Here&#8217;s the response from the call<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-15.59.23-473x1024.png\" alt=\"\" class=\"wp-image-1174\" width=\"299\" height=\"648\" srcset=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-15.59.23-473x1024.png 473w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-15.59.23-139x300.png 139w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-15.59.23-768x1662.png 768w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-15.59.23-710x1536.png 710w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-15.59.23-946x2048.png 946w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-15.59.23.png 1170w\" sizes=\"auto, (max-width: 299px) 100vw, 299px\" \/><\/figure>\n\n\n\n<p>Moving on, let&#8217;s render just the breeds and display without any form of styling. We should be able to see something on the screen.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">renderCats = ({item}) =&gt; (\n    &lt;View style={{marginTop: 0}}&gt;\n       &lt;Text&gt;{item.breed}&lt;\/Text&gt;\n    &lt;\/View&gt;\n  );\n\n     &lt;FlatList\n        removeClippedSubviews={true}\n        data={this.state.data}\n        renderItem={item =&gt; this.renderCats(item)}\n      \/&gt;<\/code><\/pre>\n\n\n\n<p>So here, we&#8217;re getting the items and we&#8217;re displaying in our FlatList. Here is what it looks like:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-16.14.07-473x1024.png\" alt=\"\" class=\"wp-image-1175\" width=\"248\" height=\"537\" srcset=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-16.14.07-473x1024.png 473w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-16.14.07-139x300.png 139w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-16.14.07-768x1662.png 768w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-16.14.07-710x1536.png 710w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-16.14.07-946x2048.png 946w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-16.14.07.png 1170w\" sizes=\"auto, (max-width: 248px) 100vw, 248px\" \/><\/figure>\n\n\n\n<p>Next let&#8217;s use ListView from react-native-elements<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">yarn add react-native-elements\nyarn add react-native-vector-icons \/\/ Add icons\ncd iOS\npod install<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">renderCats = ({item}) =&gt; (\n    &lt;View style={{marginTop: 0}}&gt;\n    &lt;ListItem bottomDivider containerStyle={{ backgroundColor: '#fbb03c' }}&gt;\n    &lt;Avatar rounded large source={{uri: 'https:\/\/cdn-prod.medicalnewstoday.com\/content\/images\/articles\/322\/322868\/golden-retriever-puppy.jpg'}} height={36} width={36} \/&gt;\n     &lt;ListItem.Content&gt;\n       &lt;ListItem.Title style={{color:'black', fontSize: 18}}&gt;{item.breed.toUpperCase()}&lt;\/ListItem.Title&gt;\n       &lt;ListItem.Subtitle style={{color: 'black'}}&gt;{item.country}&lt;\/ListItem.Subtitle&gt;\n     &lt;\/ListItem.Content&gt;\n   &lt;\/ListItem&gt;\n    &lt;\/View&gt;\n  );<\/code><\/pre>\n\n\n\n<p>We also add a bit of styling to it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"jsx\" class=\"language-jsx\">\/**\n * Sample React Native App\n * https:\/\/github.com\/facebook\/react-native\n *\n * @format\n * @flow strict-local\n *\/\n\nimport React, { PureComponent } from 'react';\nimport {\n  StatusBar,\n  StyleSheet,\n  SafeAreaView,\n  Text,\n  View,\n  TouchableOpacity,\n  FlatList\n} from 'react-native';\nimport { ListItem, Avatar } from 'react-native-elements';\nimport Icon from 'react-native-vector-icons\/Ionicons'\n\nclass App extends PureComponent {\n\n  constructor(props){\n    super(props);\n    this.state = {\n      data: []\n    }\n  }\n\n\n  fetchItem() {\n      requestAnimationFrame(() =&gt;\n        fetch(`https:\/\/catfact.ninja\/breeds`, {\n          method: 'GET',\n        })\n          .then(response =&gt; response.json())\n          .then(responseJson =&gt; {\n            this.setState({data: responseJson.data})\n             console.warn(responseJson);\n          })\n          .catch(error =&gt; {\n            {\n              alert(error)\n            }\n          }),\n      );\n  }\n\n\n  renderCats = ({item}) =&gt; (\n    &lt;View style={{marginTop: 0}}&gt;\n    &lt;ListItem bottomDivider containerStyle={{ backgroundColor: '#fbb03c' }}&gt;\n    &lt;Avatar rounded large source={{uri: 'https:\/\/cdn-prod.medicalnewstoday.com\/content\/images\/articles\/322\/322868\/golden-retriever-puppy.jpg'}} height={36} width={36} \/&gt;\n     &lt;ListItem.Content&gt;\n       &lt;ListItem.Title style={{color:'black', fontSize: 18}}&gt;{item.breed.toUpperCase()}&lt;\/ListItem.Title&gt;\n       &lt;ListItem.Subtitle style={{color: 'black'}}&gt;{item.country}&lt;\/ListItem.Subtitle&gt;\n     &lt;\/ListItem.Content&gt;\n   &lt;\/ListItem&gt;\n    &lt;\/View&gt;\n  );\n\n\n  componentDidMount(){\n    this.fetchItem()\n  }\n\n  render(){\n    return(\n      &lt;SafeAreaView style={{ flex: 1, backgroundColor: '#fbb03c' }}&gt;\n      &lt;FlatList\n        removeClippedSubviews={true}\n        data={this.state.data}\n        renderItem={item =&gt; this.renderCats(item)}\n      \/&gt;\n    &lt;\/SafeAreaView&gt;\n      )\n  }\n}\n\nexport default App;\n<\/code><\/pre>\n\n\n\n<p>Here&#8217;s the full source code on our <a href=\"https:\/\/github.com\/Codeflare-Limited\/react-native-flatlist\" target=\"_blank\" rel=\"noreferrer noopener\">Github Repo<\/a>. Don&#8217;t forget to follow us on Github and our social media handles <strong>@codeflaretech<\/strong>.<\/p>\n\n\n\n<p>Don&#8217;t forget to follow<\/p>\n\n\n\n<p>TADA!<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"473\" height=\"1024\" src=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-18.47.51-1-473x1024.png\" alt=\"\" class=\"wp-image-1179\" srcset=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-18.47.51-1-473x1024.png 473w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-18.47.51-1-139x300.png 139w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-18.47.51-1-768x1662.png 768w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-18.47.51-1-710x1536.png 710w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-18.47.51-1-946x2048.png 946w, https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Simulator-Screen-Shot-iPhone-13-2023-01-02-at-18.47.51-1.png 1170w\" sizes=\"auto, (max-width: 473px) 100vw, 473px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>The FlatList component is an effective way to display items in a scrollable list view. We can fetch<\/p>\n","protected":false},"author":1,"featured_media":1180,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[98],"tags":[],"class_list":["post-1172","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-softare-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fetch Data From an API and Display in FlatList in React Native<\/title>\n<meta name=\"description\" content=\"We can fetch data from an API and display in FlatList in React Native. It is a useful alternative to ScrollViews\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fetch Data From an API and Display in FlatList in React Native\" \/>\n<meta property=\"og:description\" content=\"We can fetch data from an API and display in FlatList in React Native. It is a useful alternative to ScrollViews\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/facebook.com\/codeflretech\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-02T18:51:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-02T18:51:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Untitled-Design-2.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"codeflare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codeflaretech\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/\"},\"author\":{\"name\":\"codeflare\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\"},\"headline\":\"Fetch Data From an API and Display in FlatList in React Native\",\"datePublished\":\"2023-01-02T18:51:41+00:00\",\"dateModified\":\"2023-01-02T18:51:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/\"},\"wordCount\":304,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Untitled-Design-2.jpeg\",\"articleSection\":[\"softare development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/\",\"name\":\"Fetch Data From an API and Display in FlatList in React Native\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Untitled-Design-2.jpeg\",\"datePublished\":\"2023-01-02T18:51:41+00:00\",\"dateModified\":\"2023-01-02T18:51:43+00:00\",\"description\":\"We can fetch data from an API and display in FlatList in React Native. It is a useful alternative to ScrollViews\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/#primaryimage\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Untitled-Design-2.jpeg\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/01\\\/Untitled-Design-2.jpeg\",\"width\":1200,\"height\":628,\"caption\":\"use FlatList in react native\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"softare development\",\"item\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/softare-development\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Fetch Data From an API and Display in FlatList in React Native\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"name\":\"\",\"description\":\"Sustainable solutions\",\"publisher\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#organization\",\"name\":\"Codeflare Limited\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"contentUrl\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/codeflare.png\",\"width\":1040,\"height\":263,\"caption\":\"Codeflare Limited\"},\"image\":{\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/#\\\/schema\\\/person\\\/7e65653d49add95629f8c1053c5cd76a\",\"name\":\"codeflare\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g\",\"caption\":\"codeflare\"},\"description\":\"Latest tech news and coding tips.\",\"sameAs\":[\"https:\\\/\\\/codeflarelimited.com\\\/blog\",\"https:\\\/\\\/facebook.com\\\/codeflretech\",\"https:\\\/\\\/instagram.com\\\/codeflaretech\",\"https:\\\/\\\/x.com\\\/codeflaretech\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1\"],\"url\":\"https:\\\/\\\/codeflarelimited.com\\\/blog\\\/author\\\/watcher\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fetch Data From an API and Display in FlatList in React Native","description":"We can fetch data from an API and display in FlatList in React Native. It is a useful alternative to ScrollViews","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/","og_locale":"en_US","og_type":"article","og_title":"Fetch Data From an API and Display in FlatList in React Native","og_description":"We can fetch data from an API and display in FlatList in React Native. It is a useful alternative to ScrollViews","og_url":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/","article_author":"https:\/\/facebook.com\/codeflretech","article_published_time":"2023-01-02T18:51:41+00:00","article_modified_time":"2023-01-02T18:51:43+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Untitled-Design-2.jpeg","type":"image\/jpeg"}],"author":"codeflare","twitter_card":"summary_large_image","twitter_creator":"@codeflaretech","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/#article","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/"},"author":{"name":"codeflare","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a"},"headline":"Fetch Data From an API and Display in FlatList in React Native","datePublished":"2023-01-02T18:51:41+00:00","dateModified":"2023-01-02T18:51:43+00:00","mainEntityOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/"},"wordCount":304,"commentCount":0,"publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Untitled-Design-2.jpeg","articleSection":["softare development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/","url":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/","name":"Fetch Data From an API and Display in FlatList in React Native","isPartOf":{"@id":"https:\/\/codeflarelimited.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/#primaryimage"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/#primaryimage"},"thumbnailUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Untitled-Design-2.jpeg","datePublished":"2023-01-02T18:51:41+00:00","dateModified":"2023-01-02T18:51:43+00:00","description":"We can fetch data from an API and display in FlatList in React Native. It is a useful alternative to ScrollViews","breadcrumb":{"@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/#primaryimage","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Untitled-Design-2.jpeg","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Untitled-Design-2.jpeg","width":1200,"height":628,"caption":"use FlatList in react native"},{"@type":"BreadcrumbList","@id":"https:\/\/codeflarelimited.com\/blog\/fetch-data-from-an-api-and-display-in-flatlist-in-react-native\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codeflarelimited.com\/blog\/"},{"@type":"ListItem","position":2,"name":"softare development","item":"https:\/\/codeflarelimited.com\/blog\/softare-development\/"},{"@type":"ListItem","position":3,"name":"Fetch Data From an API and Display in FlatList in React Native"}]},{"@type":"WebSite","@id":"https:\/\/codeflarelimited.com\/blog\/#website","url":"https:\/\/codeflarelimited.com\/blog\/","name":"","description":"Sustainable solutions","publisher":{"@id":"https:\/\/codeflarelimited.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codeflarelimited.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codeflarelimited.com\/blog\/#organization","name":"Codeflare Limited","url":"https:\/\/codeflarelimited.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","contentUrl":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2020\/11\/codeflare.png","width":1040,"height":263,"caption":"Codeflare Limited"},"image":{"@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/codeflarelimited.com\/blog\/#\/schema\/person\/7e65653d49add95629f8c1053c5cd76a","name":"codeflare","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/59cef917c86d965eea581d2747f51bd6382003a68bfce7c8a4dfec98b4cd838d?s=96&d=mm&r=g","caption":"codeflare"},"description":"Latest tech news and coding tips.","sameAs":["https:\/\/codeflarelimited.com\/blog","https:\/\/facebook.com\/codeflretech","https:\/\/instagram.com\/codeflaretech","https:\/\/x.com\/codeflaretech","https:\/\/www.youtube.com\/channel\/UCuBLtiYqsajHdqw0uyt7Ofw?sub_confirmation=1"],"url":"https:\/\/codeflarelimited.com\/blog\/author\/watcher\/"}]}},"jetpack_featured_media_url":"https:\/\/codeflarelimited.com\/blog\/wp-content\/uploads\/2023\/01\/Untitled-Design-2.jpeg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/comments?post=1172"}],"version-history":[{"count":2,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1172\/revisions"}],"predecessor-version":[{"id":1181,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/posts\/1172\/revisions\/1181"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media\/1180"}],"wp:attachment":[{"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/media?parent=1172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/categories?post=1172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codeflarelimited.com\/blog\/wp-json\/wp\/v2\/tags?post=1172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}