O'Reilly logo

React Native Cookbook by Crysfel Villa, Stan Bershadskiy

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

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', ...

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