- Using JavaScript logic such as the .map function to iterate through the array in JSX and create a component for each item.
- Using a React Native FlatList component which takes in a array object.
Create FlatList
- First, import FlatList, View, and StyleSheet from ‘react-native’ in
LandingScreen.tsx.
- Replace the VideoCard component with a FlatList component.
- Add the
horizontalprop to display the items horizontally. - Add the
dataprop to FlatList and set it toislandVideos. This is the source data that the FlatList will render.
- Add the
renderItemprop. It passes anitemfrom thedataprop (in our case, a single video element) to an arrow function, where you specify the JSX that will render that item. - Add the VideoCard component to
renderItemand wrap it in a View. - Add the
keyprop to VideoCard, which is used by FlatList to track items (the key must be unique). You could also add akeyExtractorprop to FlatList, instead of specifying akeyin VideoCard. You can learn more about this in the React Native FlatList documentation. - Add the
title,description, andimgURLprops to the VideoCard component, and pass in the corresponding fields fromitem. - Create a second FlatList for the
underwaterVideos. - Add a
Textcomponent to each row to label the category.
- Refresh the app and verify the VideoCards are rendering.
Add Styling
Let’s add some styling to make the VideoCards look nicer on the screen.- After the LandingScreen arrow function, create a StyleSheet with styles called
flatList,itemContainerandcategoryTitle. These styles will give our cards some spacing and make our category title look a bit nicer.
- Now add the
flatListstyle to FlatList, theitemContainerstyle to View and thecategoryTitleto the Text.
Wrap rows in TVFocusGuideView
Now in order to ensure that focus is handled between the 2 rows we can use the TVFocusGuideView component. The component enables your app to find, recover and remembering the focus on multiple visits.- Import
TVFocusGuideViewfrom@amazon-devices/react-native-kepler.
- Wrap the FlatList in the TVFocusGuideView and set autoFocus to true, this enables TVFocusGuide to automatically manage focus for you.
LandingScreen.tsx should look like this:
- Refresh the app, and navigate from one row to another. Notice that focus is retained on the item you navigated from rather than moving to a corresponding item in the new row? This behavior is controlled by the TVFocusGuideView component!

Focus navigation according to TVFocusGuideView

