O'Reilly logo

React Native By Example by Richard Kho

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

Custom RenderRow example

Let's look at how I created this component:

// Tasks/app/components/TasksList/index.js ... import TasksListCell from '../TasksListCell'; ... export default class TasksList extends Component {   ...   async _addTask () {     const singleTask = {       completed: false,       text: this.state.text     } 

Firstly, tasks are now represented as objects within the array. This allows us to add properties to each task, such as its completed state, and leaves room for future additions.

    const listOfTasks = [...this.state.listOfTasks, singleTask];     await AsyncStorage.setItem('listOfTasks',     JSON.stringify(listOfTasks));     this._updateList();   }   ...   _renderRowData (rowData, rowID) {     return (       <TasksListCell  completed={ rowData.completed } ...

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