O'Reilly logo

React and React Native by Adam Boduch

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

Completing todo items

The last piece of this application is rendering each todo item and providing the ability to change the status of the todo. Let's take a look at this code:

import React, { Component, PropTypes } from 'react'; import Relay from 'react-relay'; import { Text, View, Switch, } from 'react-native'; import styles from './styles'; import ChangeTodoStatusMutation from './mutations/ChangeTodoStatusMutation'; // How to style the todo text, based on the // boolean value of the "completed" property. const completeStyleMap = new Map([ [true, { textDecorationLine: 'line-through' }], [false, {}], ]); class Todo extends Component { static propTypes = { relay: PropTypes.any.isRequired, viewer: PropTypes.any.isRequired, todo: PropTypes.shape({ ...

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