One of the benefits of using React Native is its ability to easily create universal apps. We can share a lot of code for phone and tablet apps. The layouts might be different at some point, but we can reuse the small pieces for both devices.
In this recipe, we will build an app that runs on phones and tablets. The tablet version will include a different layout, but we will reuse the same internal components.
For this recipe, we will show a list of contacts. For now, we will load the data from a .json
file; later on, in the book, we will explore how to load remote data from a REST API.
Let's open the following URL and copy the generated JSON to a file called src/data.json
. We will use this data to render the list of contacts http://api.randomuser.me/?results=20:
You might want to register to this service and get a key; otherwise, they will only allow you to make a few requests to the assets and API, and since we are going to load the images from there...