March 2017
Beginner to intermediate
500 pages
9h 41m
English
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({ ...Read now
Unlock full access