Removing items from a list component

In this recipe, we will learn how to drag elements from a ListView to remove them. We are going to use the PanResponder to handle the drag events.

Getting ready

We need to create an empty app. For this recipe, we will name it ListRemoveItems. Feel free to use any other name, just make sure to use the correct name in step 1.

We also need to create three files: src/MainApp.js, src/ContactList/index.js, and src/ContactList/ContactItem.js.

How to do it...

  1. Open the index.ios.js and index.android.js files, remove the existing code, and add the following:
            import React from 'react';         import { AppRegistry } from 'react-native';         import MainApp from './src/MainApp';         AppRegistry.registerComponent('ListRemoveItems', ...

Get React Native Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.