O'Reilly logo

React Native By Example by Richard Kho

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Optimizing for the API

The current rate limit for Facebook's Graph API is 200 calls per hour per user. This means that if your app has 100 users, you can make 20,000 calls per hour. The limit is in aggregate, meaning that any single user could take up all 20,000 calls in that given hour.

To reduce the number of network calls we make to the API, we should tweak our App component to save feed data within AsyncStorage and only refresh its data when manually prompted to do so by the user.

We can begin by creating methods for AsyncStorage, which are similar to the ones we had in Expenses:

// Friends/app/utils/storageMethods.js import { AsyncStorage } from 'react-native';  export const getAsyncStorage = async (key) => {  let response = await AsyncStorage.getItem(key); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required