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({ text: PropTypes.string.isRequired, complete: PropTypes.bool.isRequired, }), } // Handles the...