Make VideoCards focusable and pressable
Now we need to make the VideoCards focusable and pressable to enable us to interact and navigate to them. We’ll do that using a component called TouchableOpacity.- Open
VideoCard.tsxand import TouchableOpacity from ‘react-native’.
- Replace the View element with TouchableOpacity. Leave the
styleprop.
onPress() handler.
- Pass a new prop to the VideoCard called
pressFunctionand give it a type of Function - Add the
onPressprop to TouchableOpacity and set its value to call the newpressFunction
onFocus() and onBlur() properties to the TouchableOpacity
- Import
useStatefrom react and initialize it with a state offocusedand a function ofsetFocused. - Initialize the value of
focusedto false.
- Add an
onFocusprop to the TouchableOpacity, and set it to call thesetFocused()function with the valuetrue - Add an
onBlurprop to the TouchableOpacity, and set it to call thesetFocused()function with the valuefalse
- Modify the
videoCardContaineras below. - Create two new style props called focused and unfocused and set their styles as below.
- Modify the TouchableOpacity to add a new style prop depending on the value of focused (focused if true and unfocused if false)
VideoCard.tsx code should look like this:
- Refresh the app. You should now be able to focus on a video card by pressing any of the keys on the D-pad / arrow keys on your keyboard, as seen in the video below.

Video card focus

